function getI18NString(t) {
	if (!i18n[lang]) return t;
	var e = i18n[lang][t];
	return void 0 === e ? t : e;
}
function override(t, e, i) {
	var n = t.prototype[e];
	t.prototype[e] = function() {
		return n.apply(this, arguments), i.apply(this, arguments);
	};
}
function GridBackground(t) {
	(this.graph = t),
		t.onPropertyChange("viewport", this.update.bind(this)),
		t.onPropertyChange("transform", this.update.bind(this)),
		(this.canvas = Q.createCanvas(t.width, t.height, !0)),
		(this.canvas.style.position = "absolute"),
		(this.canvas.style.top = "0px"),
		(this.canvas.style["-webkit-user-select"] = "none"),
		(this.canvas.style["-webkit-tap-highlight-color"] = "rgba(0, 0, 0, 0)"),
		(this.scaleCanvas = Q.createCanvas(t.width, t.height, !0)),
		(this.scaleCanvas.style.position = "absolute"),
		(this.scaleCanvas.style.top = "0px"),
		(this.scaleCanvas.style["-webkit-user-select"] = "none"),
		(this.scaleCanvas.style["-webkit-tap-highlight-color"] = "rgba(0, 0, 0, 0)"),
		t.canvasPanel.insertBefore(this.canvas, t.canvasPanel.firstChild),
		t.canvasPanel.appendChild(this.scaleCanvas),
		this.update();
}
var i18n = {
		"zh-cn": {
			Name: "名称",
			"Render Color": "渲染色",
			Border: "边框",
			"Border Color": "边框颜色",
			Location: "坐标",
			Size: "尺寸",
			Rotate: "旋转",
			"Label Color": "文本颜色",
			"Background Color": "背景色",
			"Font Size": "字体大小",
			"json file is empty": "JSON文件为空",
			"Save Error": "保存错误",
			"Save Success": "保存成功",
			Update: "更新",
			Submit: "提交",
			"Export JSON": "导出JSON",
			"Load File ...": "加载文件 ...",
			"Download File": "下载文件",
			Save: "保存",
			Rename: "重命名",
			"Input Element Name": "输入图元名称",
			"Solid Line": "实线样式",
			"Dashed Line": "虚线样式",
			"Line Width": "连线宽度",
			"Input Line Width": "输入连线宽度",
			"Line Color": "连线颜色",
			"Input Line Color": "输入连线颜色",
			"Out of Group": "脱离分组",
			"Send to Top": "置顶显示",
			"Send to Bottom": "置底显示",
			"Reset Layer": "恢复默认层",
			"Clear Graph": "清空画布",
			"Zoom In": "放大",
			"Zoom Out": "缩小",
			"1:1": "1:1",
			"Pan Mode": "平移模式",
			"Rectangle Select": "框选模式",
			Text: "文字",
			"Basic Nodes": "基本节点",
			"Register Images": "注册图片",
			"Default Shapes": "默认形状",
		},
	},
	lang = navigator.language || navigator.browserLanguage;
(lang = lang.toLowerCase()),
	(Q.Graph.prototype.copy = function() {
		var t = this.selectionModel.toDatas();
		this._copyElements = t;
	}),
	(Q.Graph.prototype.paste = function(t, e) {
		function i(t) {
			n[t.id] || ((n[t.id] = t), t.hasChildren() && t.forEachChild(i), t instanceof Q.Edge && (i(t.from), i(t.to)));
		}
		if (this._copyElements) {
			(t = t || 0), (e = e || 0);
			var n = {};
			this._copyElements.forEach(i);
			for (var o in n) {
				var r = n[o];
				r instanceof Q.Node &&
					r.hasEdge() &&
					r.forEachEdge(function(t) {
						var e = t.otherNode(r);
						e && n[e.id] && (n[t.id] = t);
					});
			}
			var a = this.exportJSON(!0, {
					filter: function(t) {
						return t.id in n;
					}.bind(this),
				}),
				s = this.parseJSON(a);
			s.forEach(function(i) {
				i instanceof Q.Node && ((i.x = i.x + t), (i.y = i.y + e));
			}),
				this.setSelection(s);
		}
	}),
	override(Q.EditInteraction, "onkeydown", function(t, e) {
		var i = t.keyCode;
		if (Q.isMetaKey(t)) {
			if (67 == i) e.copy();
			else if (86 == i) e.paste(20, 20);
			else if (90 == i);
			else if (89 != i) return;
			Q.stopEvent(t);
		}
	}),
	!(function(t, e) {
		var i = function(t) {
			t = t || {};
			var i = document.createElement(t.tagName || "div");
			return (
				t.class && e(i).addClass(t.class),
				t.parent && t.parent.appendChild(i),
				t.style && i.setAttribute("style", t.style),
				t.css && e(i).css(t.css),
				t.html && e(i).html(t.html),
				i
			);
		};
		t.createElement = i;
	})(Q, jQuery),
	!(function(t) {
		function e(t) {
			t = t || window.event;
			var e = t.dataTransfer,
				i = t.target;
			e.setData("text", i.getAttribute(o));
		}
		function i(t, e, i, o) {
			var r = document.createElement("img");
			return (
				(r.src = e),
				r.setAttribute("title", i),
				(o = o || {}),
				(o.label = o.label || i),
				(o.title = i),
				o.image || (o.type && "Node" != o.type) || (o.image = e),
				n(r, o),
				t.appendChild(r),
				r
			);
		}
		function n(i, n) {
			return (
				i.setAttribute("draggable", "true"),
				i.setAttribute(o, t.exportJSON ? t.exportJSON(n, !0) : JSON.stringify(n)),
				(i.ondragstart = e),
				i
			);
		}
		var o = "draginfo",
			r = /MSIE 9/i.test(navigator.userAgent) || /MSIE 10/i.test(navigator.userAgent),
			a = !r;
		if (!a) {
			var s = {},
				l = function(t) {
					return { x: t.pageX, y: t.pageY };
				},
				h = document.documentElement,
				u = function() {
					h.addEventListener(
						"mousemove",
						function(e) {
							if (s.target) {
								t.stopEvent(e);
								var i = l(e);
								if (!s.dragElement) {
									var n = s.target;
									if (Math.abs(i.x - s.dragPoint.x) <= 5 || Math.abs(i.y - s.dragPoint.y) <= 5) return;
									var o = document.createElement("div");
									(o.style.position = "absolute"), (o.style.zIndex = 1e4);
									var r = n.cloneNode(!0);
									/canvas/i.test(r.tagName)
										? r.getContext("2d").drawImage(n, 0, 0)
										: ((o.style.maxWidth = "30px"), (o.style.maxWidth = "30px"), (o.style.cursor = "move")),
										(r.id = null),
										o.appendChild(r),
										h.appendChild(o),
										(s.dragElement = o);
									var a = { target: n };
									n.ondragstart instanceof Function &&
										((s.dataTransfer = a.dataTransfer = {
											datas: {},
											setData: function(t, e) {
												this.datas[t] = e;
											},
											getData: function(t) {
												return this.datas[t];
											},
										}),
										n.ondragstart(a));
								}
								(s.dragElement.style.left = i.x - s.dragElement.clientWidth / 2 + "px"),
									(s.dragElement.style.top = i.y - s.dragElement.clientHeight / 2 + "px");
							}
						},
						!1
					),
						h.addEventListener(
							"mouseup",
							function(t) {
								if (s.target) {
									delete s.dragPoint,
										delete s.target,
										s.dragElement && (h.removeChild(s.dragElement), delete s.dragElement);
									for (var e = l(t), i = document.getElementsByClassName("Q-CanvasPanel"), n = 0; n < i.length; ) {
										var o = i[n];
										++n;
										var r = c(o);
										if (p(r, e)) {
											o.ondrop instanceof Function && ((t.dataTransfer = s.dataTransfer), o.ondrop(t));
											break;
										}
									}
									delete s.dataTransfer;
								}
							},
							!1
						);
				},
				p = function(t, e) {
					return e.x >= t.x && e.x <= t.x + t.width && e.y >= t.y && e.y <= t.y + t.height;
				},
				d = function(t) {
					for (var e = 0, i = 0; t.offsetParent; )
						(e += t.clientLeft + t.offsetLeft - t.scrollLeft),
							(i += t.clientTop + t.offsetTop - t.scrollTop),
							(t = t.offsetParent);
					return { x: e, y: i };
				},
				c = function(t) {
					var e = d(t),
						i = e.x + t.scrollLeft,
						n = e.y + t.scrollTop,
						o = t.clientWidth,
						r = t.clientHeight;
					return { x: i, y: n, left: i, top: n, right: i + o, bottom: n + r, width: o, height: r };
				},
				f = function(e) {
					return (
						(e.onmousedown = function(i) {
							(s.dragPoint = l(i)), (s.target = e), t.stopEvent(i);
						}),
						e
					);
				};
			(n = function(t, i) {
				return t.setAttribute("draggable", "true"), t.setAttribute(o, JSON.stringify(i)), (t.ondragstart = e), f(t), t;
			}),
				u();
		}
		(t.createDNDImage = i), (t.appendDNDInfo = n);
	})(Q),
	!(function(t) {
		var e =
			e ||
			("undefined" != typeof navigator && navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator)) ||
			(function(t) {
				"use strict";
				if ("undefined" == typeof navigator || !/MSIE [1-9]\./.test(navigator.userAgent)) {
					var e = t.document,
						i = function() {
							return t.URL || t.webkitURL || t;
						},
						n = e.createElementNS("http://www.w3.org/1999/xhtml", "a"),
						o = "download" in n,
						r = function(i) {
							var n = e.createEvent("MouseEvents");
							n.initMouseEvent("click", !0, !1, t, 0, 0, 0, 0, 0, !1, !1, !1, !1, 0, null), i.dispatchEvent(n);
						},
						a = t.webkitRequestFileSystem,
						s = t.requestFileSystem || a || t.mozRequestFileSystem,
						l = function(e) {
							(t.setImmediate || t.setTimeout)(function() {
								throw e;
							}, 0);
						},
						h = "application/octet-stream",
						u = 0,
						p = 500,
						d = function(e) {
							var n = function() {
								"string" == typeof e ? i().revokeObjectURL(e) : e.remove();
							};
							t.chrome ? n() : setTimeout(n, p);
						},
						c = function(t, e, i) {
							e = [].concat(e);
							for (var n = e.length; n--; ) {
								var o = t["on" + e[n]];
								if ("function" == typeof o)
									try {
										o.call(t, i || t);
									} catch (r) {
										l(r);
									}
							}
						},
						f = function(e, l) {
							var p,
								f,
								g,
								m = this,
								v = e.type,
								y = !1,
								_ = function() {
									c(m, "writestart progress write writeend".split(" "));
								},
								b = function() {
									if (((y || !p) && (p = i().createObjectURL(e)), f)) f.location.href = p;
									else {
										var n = t.open(p, "_blank");
										void 0 == n && "undefined" != typeof safari && (t.location.href = p);
									}
									(m.readyState = m.DONE), _(), d(p);
								},
								S = function(t) {
									return function() {
										return m.readyState !== m.DONE ? t.apply(this, arguments) : void 0;
									};
								},
								E = { create: !0, exclusive: !1 };
							return (
								(m.readyState = m.INIT),
								l || (l = "download"),
								o
									? ((p = i().createObjectURL(e)),
									  (n.href = p),
									  (n.download = l),
									  r(n),
									  (m.readyState = m.DONE),
									  _(),
									  void d(p))
									: (t.chrome &&
											v &&
											v !== h &&
											((g = e.slice || e.webkitSlice), (e = g.call(e, 0, e.size, h)), (y = !0)),
									  a && "download" !== l && (l += ".download"),
									  (v === h || a) && (f = t),
									  s
											? ((u += e.size),
											  void s(
													t.TEMPORARY,
													u,
													S(function(t) {
														t.root.getDirectory(
															"saved",
															E,
															S(function(t) {
																var i = function() {
																	t.getFile(
																		l,
																		E,
																		S(function(t) {
																			t.createWriter(
																				S(function(i) {
																					(i.onwriteend = function(e) {
																						(f.location.href = t.toURL()),
																							(m.readyState = m.DONE),
																							c(m, "writeend", e),
																							d(t);
																					}),
																						(i.onerror = function() {
																							var t = i.error;
																							t.code !== t.ABORT_ERR && b();
																						}),
																						"writestart progress write abort"
																							.split(" ")
																							.forEach(function(t) {
																								i["on" + t] = m["on" + t];
																							}),
																						i.write(e),
																						(m.abort = function() {
																							i.abort(), (m.readyState = m.DONE);
																						}),
																						(m.readyState = m.WRITING);
																				}),
																				b
																			);
																		}),
																		b
																	);
																};
																t.getFile(
																	l,
																	{ create: !1 },
																	S(function(t) {
																		t.remove(), i();
																	}),
																	S(function(t) {
																		t.code === t.NOT_FOUND_ERR ? i() : b();
																	})
																);
															}),
															b
														);
													}),
													b
											  ))
											: void b())
							);
						},
						g = f.prototype,
						m = function(t, e) {
							return new f(t, e);
						};
					return (
						(g.abort = function() {
							var t = this;
							(t.readyState = t.DONE), c(t, "abort");
						}),
						(g.readyState = g.INIT = 0),
						(g.WRITING = 1),
						(g.DONE = 2),
						(g.error = g.onwritestart = g.onprogress = g.onwrite = g.onabort = g.onerror = g.onwriteend = null),
						m
					);
				}
			})(("undefined" != typeof self && self) || ("undefined" != typeof t && t) || this.content);
		"undefined" != typeof module && null !== module
			? (module.exports = e)
			: "undefined" != typeof define &&
			  null !== define &&
			  null != define.amd &&
			  define([], function() {
					return e;
			  }),
			(t.saveAs = e);
	})(window, document),
	!(function(t) {
		function e(e, i, n) {
			var o = e.name;
			if (t.isString(i)) {
				var r = new RegExp("." + i + "$", "gi");
				if (!r.test(o)) return void alert("Please selects ." + i + " file");
			} else i instanceof Function && (n = i);
			var a = new FileReader();
			(a.onload = function() {
				n(a.result);
			}),
				a.readAsText(e, "utf-8");
		}
		(window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem),
			(t.isFileSupported = null != window.requestFileSystem),
			t.isFileSupported && (t.readerSingleFile = e);
	})(Q),
	!(function(t, e) {
		function i(t) {
			if (!(t instanceof Object)) return !t;
			if (Array.isArray(t)) return 0 == t.length;
			for (var e in t) return !1;
			return !0;
		}
		function n(t, i) {
			var n = t.split(".");
			i = i || e;
			for (var o = -1; i && ++o < n.length; ) {
				var r = n[o];
				i = i[r];
			}
			return i;
		}
		function o(t, e, i) {
			if (
				((t._classPath = e), t instanceof Function && ((t.prototype._className = t._classPath), (t.prototype._class = t)), i !== !1)
			)
				for (var n in t)
					if (
						!("_" == n[0] || "$" == n[0] || "superclass" == n || "constructor" == n || "prototype" == n || n.indexOf(".") >= 0)
					) {
						var r = t[n];
						r && r instanceof Object && !r._classPath && o(r, e + "." + n);
					}
		}
		function r(t) {
			var e = t._className;
			if (!e) return null;
			var i = p[e];
			if (!i) {
				var n = t._class;
				i = p[e] = new n();
			}
			return i;
		}
		function a(t, e) {
			return t == e || (t && e && t.equals && t.equals(e));
		}
		function s(t, e, i, n) {
			var o = r(n);
			e.forEach(function(e) {
				var r = n[e];
				if (!a(r, o[e])) {
					var s = t.toJSON(r);
					(s || !r) && (i[e] = s);
				}
			}, n);
		}
		function l(t, e) {
			var i;
			for (var n in e) i || (i = {}), (i[n] = t.toJSON(e[n]));
			return i;
		}
		function h(t) {
			t && (this.withGlobalRefs = t.withGlobalRefs !== !1), this.reset();
		}
		function u(t, e) {
			var n = new h(),
				o = { version: "2.0", refs: {} },
				r = [],
				a = {};
			if (t.currentSubNetwork) {
				var s = n.elementToJSON(t.currentSubNetwork);
				s && (o.currentSubNetwork = { _ref: (s._refId = t.currentSubNetwork.id) });
			}
			if (
				(t.forEach(function(t) {
					if (!e || e(t) !== !1) {
						var i = n.elementToJSON(t);
						i && (r.push(i), (a[t.id] = i));
					}
				}),
				n._elementRefs)
			)
				for (var l in n._elementRefs) a[l]._refId = l;
			n._globalRefs && (o.refs = n._globalRefs), n.clearRef(), (o.datas = r);
			for (var u in o) i(o[u]) && delete o[u];
			return o;
		}
		if (!t.Graph.prototype.parseJSON) {
			var p = {};
			(t.HashList.prototype.toJSON = function(t) {
				var e = [];
				return (
					this.forEach(function(i) {
						e.push(t.toJSON(i));
					}),
					e
				);
			}),
				(t.HashList.prototype.parseJSON = function(t, e) {
					var i = [];
					return (
						t.forEach(function(t) {
							var n = e.parseJSON(t);
							this.add(n), i.push(n);
						}, this),
						i
					);
				});
			var d = {
				class: !1,
				id: !1,
				fillGradient: !1,
				syncSelectionStyles: !1,
				originalBounds: !1,
				parent: !1,
				font: !1,
				$data: !1,
				$x: !1,
				$y: !1,
			};
			(t.BaseUI.prototype.toJSON = function(t) {
				var e = {};
				for (var i in this)
					if ("_" != i[0] && ("$" != i[0] || "_" != i[1]) && 0 != i.indexOf("$invalidate") && d[i] !== !1) {
						var n = this[i];
						if (!(n instanceof Function || n == this.class.prototype[i]))
							try {
								e[i] = t.toJSON(n);
							} catch (o) {}
					}
				return e;
			}),
				(t.BaseUI.prototype.parseJSON = function(t, e) {
					for (var i in t) {
						var n = e.parseJSON(t[i]);
						this[i] = n;
					}
				});
			var c = [
				"rotatable",
				"editable",
				"layoutable",
				"visible",
				"busLayout",
				"enableSubNetwork",
				"zIndex",
				"tooltipType",
				"tooltip",
				"movable",
				"selectable",
				"resizable",
				"uiClass",
				"name",
				"parent",
				"host",
			];
			(t.Element.prototype.addOutProperty = function(t) {
				this.outputProperties || (this.outputProperties = []), this.outputProperties.push(t);
			}),
				(t.Element.prototype.removeOutProperty = function(t) {
					if (this.outputProperties) {
						var e = this.outputProperties.indexOf(t);
						e >= 0 && this.outputProperties.splice(e, 1);
					}
				}),
				(t.Element.prototype.toJSON = function(t) {
					var e = {},
						i = c;
					if ((this.outputProperties && (i = i.concat(this.outputProperties)), s(t, i, e, this), this.styles)) {
						var n = l(t, this.styles);
						n && (e.styles = n);
					}
					if (this.properties) {
						var o = l(t, this.properties);
						o && (e.properties = o);
					}
					var r = this.bindingUIs;
					if (r) {
						var a = [];
						r.forEach(function(e) {
							if (e.ui.serializable !== !1) {
								var i = t.toJSON(e.ui);
								a.push({ ui: i, bindingProperties: e.bindingProperties });
							}
						}),
							(e.bindingUIs = a);
					}
					return e;
				}),
				(t.Element.prototype.parseJSON = function(t, e) {
					if (t.styles) {
						var i = {};
						for (var n in t.styles) i[n] = e.parseJSON(t.styles[n]);
						this.putStyles(i, !0);
					}
					if (t.properties) {
						var o = {};
						for (var n in t.properties) o[n] = e.parseJSON(t.properties[n]);
						this.properties = o;
					}
					t.bindingUIs &&
						t.bindingUIs.forEach(function(t) {
							var i = e.parseJSON(t.ui);
							i && this.addUI(i, t.bindingProperties);
						}, this);
					for (var n in t)
						if ("id" != n && "styles" != n && "properties" != n && "bindingUIs" != n) {
							var r = e.parseJSON(t[n]);
							this[n] = r;
						}
				}),
				(t.Node.prototype.toJSON = function(e) {
					var i = t.doSuper(this, t.Node, "toJSON", arguments);
					return (
						s(
							e,
							[
								"location",
								"size",
								"image",
								"rotate",
								"anchorPosition",
								"parentChildrenDirection",
								"layoutType",
								"hGap",
								"vGap",
							],
							i,
							this
						),
						i
					);
				}),
				(t.Group.prototype.toJSON = function(e) {
					var i = t.doSuper(this, t.Group, "toJSON", arguments);
					return s(e, ["minSize", "groupType", "padding", "groupImage", "expanded"], i, this), i;
				}),
				(t.ShapeNode.prototype.toJSON = function(e) {
					var i = t.doSuper(this, t.Node, "toJSON", arguments);
					return s(e, ["location", "rotate", "anchorPosition", "path"], i, this), i;
				}),
				(t.Edge.prototype.toJSON = function(e) {
					var i = t.doSuper(this, t.Edge, "toJSON", arguments);
					return s(e, ["angle", "from", "to", "edgeType", "angle", "bundleEnabled", "pathSegments"], i, this), i;
				}),
				(h.prototype = {
					_refs: null,
					_refValues: null,
					_index: 1,
					root: null,
					reset: function() {
						(this._globalRefs = {}), (this._elementRefs = {}), (this._refs = {}), (this._refValues = {}), (this._index = 1);
					},
					getREF: function(t) {
						return this._refs[t];
					},
					clearRef: function() {
						for (var t in this._globalRefs) delete this._globalRefs[t]._value;
						for (var t in this._refValues) delete this._refValues[t]._refId;
						this.reset();
					},
					elementToJSON: function(t) {
						return this._toJSON(t);
					},
					_elementRefs: null,
					_globalRefs: null,
					withGlobalRefs: !0,
					toJSON: function(e) {
						if (!(e instanceof Object)) return e;
						if (e instanceof Function && !e._classPath) return null;
						if (!this.withGlobalRefs) return this._toJSON(e);
						if (e instanceof t.Element) return (this._elementRefs[e.id] = !0), { _ref: e.id };
						if (void 0 === e._refId) {
							var i = this._toJSON(e);
							if (!i) return i;
							var n = (e._refId = this._index++);
							return (this._refValues[n] = e), (this._refs[n] = i), i;
						}
						var n = e._refId;
						if (!this._globalRefs[n]) {
							var i = this._refs[n];
							if (!i) return i;
							var o = {};
							for (var r in i) (o[r] = i[r]), delete i[r];
							(i.$ref = n), (this._globalRefs[n] = o);
						}
						return { $ref: n };
					},
					_toJSON: function(e) {
						if (e._classPath) return { _classPath: e._classPath };
						if (!e._className) {
							if (t.isArray(e)) {
								var i = [];
								return (
									e.forEach(function(t) {
										i.push(this.toJSON(t));
									}, this),
									i
								);
							}
							i = {};
							var n;
							e.class && (n = e.class.prototype);
							for (var o in e) {
								var r = e[o];
								r instanceof Function || (n && r == n[o]) || (i[o] = this.toJSON(e[o]));
							}
							return i;
						}
						var a = { _className: e._className };
						return (a.json = e.toJSON ? e.toJSON(this) : e), a;
					},
					jsonToElement: function(t) {
						return void 0 !== t._refId && t._refId in this._refs ? this._refs[t._refId] : this._parseJSON(t);
					},
					parseJSON: function(t) {
						if (!(t instanceof Object)) return t;
						if (!this.withGlobalRefs) return this._parseJSON(t);
						if (void 0 !== t.$ref) {
							var e = this._globalRefs[t.$ref];
							if (!e) return;
							return void 0 === e._value && (e._value = this.parseJSON(e)), e._value;
						}
						if (void 0 !== t._ref) {
							var i = this._elementRefs[t._ref];
							if (!i) return;
							return this.jsonToElement(i);
						}
						return this._parseJSON(t);
					},
					_parseJSON: function(e) {
						if (!(e instanceof Object)) return e;
						if (e._classPath) return n(e._classPath);
						if (e._className) {
							var i = n(e._className),
								o = new i();
							if ((this.withGlobalRefs && void 0 !== e._refId && (this._refs[e._refId] = o), o && e.json))
								if (((e = e.json), o.parseJSON)) o.parseJSON(e, this);
								else for (var r in e) o[r] = e[r];
							return o;
						}
						if (t.isArray(e)) {
							var a = [];
							return (
								e.forEach(function(t) {
									a.push(this.parseJSON(t));
								}, this),
								a
							);
						}
						var a = {};
						for (var s in e) a[s] = this.parseJSON(e[s]);
						return a;
					},
				}),
				(t.GraphModel.prototype.toJSON = function(t) {
					return u(this, t);
				}),
				(t.GraphModel.prototype.parseJSON = function(e, i) {
					i = i || {};
					var n = e.datas;
					if (n && n.length > 0) {
						var o = [],
							r = new h(i, e.g),
							a = {};
						if (
							(n.forEach(function(t) {
								t._refId && (a[t._refId] = t);
							}),
							(r._globalRefs = e.refs || {}),
							(r._elementRefs = a),
							n.forEach(function(e) {
								var i = r.jsonToElement(e);
								i instanceof t.Element && (o.push(i), this.add(i));
							}, this),
							this.currentSubNetwork)
						) {
							var s = this.currentSubNetwork;
							o.forEach(function(t) {
								t.parent || (t.parent = s);
							});
						}
						if (e.currentSubNetwork) {
							var s = r.getREF(e.currentSubNetwork._ref);
							s && (this.currentSubNetwork = s);
						}
						return r.clearRef(), o;
					}
				}),
				(t.Graph.prototype.toJSON = t.Graph.prototype.exportJSON = function(t, e) {
					e = e || {};
					var i = this.graphModel.toJSON(e.filter);
					return (
						(i.scale = this.scale),
						(i.tx = this.tx),
						(i.ty = this.ty),
						t && (i = JSON.stringify(i, e.replacer, e.space || "	")),
						i
					);
				}),
				(t.Graph.prototype.parseJSON = function(e, i) {
					t.isString(e) && (e = JSON.parse(e)), (i = i || {});
					var n = this.graphModel.parseJSON(e, i),
						o = e.scale;
					return o && i.transform !== !1 && ((this.originAtCenter = !1), this.translateTo(e.tx || 0, e.ty || 0, o)), n;
				}),
				o(t, "Q"),
				(t.loadClassPath = o),
				(t.exportJSON = function(t, e) {
					try {
						var i = new h({ withGlobalRefs: !1 }).toJSON(t);
						return e ? JSON.stringify(i) : i;
					} catch (n) {}
				}),
				(t.parseJSON = function(e) {
					try {
						return t.isString(e) && (e = JSON.parse(e)), new h({ withGlobalRefs: !1 }).parseJSON(e);
					} catch (i) {}
				});
		}
	})(Q, window, document),
	(function(t, e) {
		function i(e, i) {
			(this.onBoundsChange = i),
				(this.parent = e),
				(this.handleSize = t.isTouchSupport ? 20 : 8),
				(this.boundsDiv = this._createDiv(this.parent)),
				(this.boundsDiv.type = "border"),
				(this.boundsDiv.style.position = "absolute"),
				(this.boundsDiv.style.border = "dashed 1px #888");
			var n = "lt,t,rt,l,r,lb,b,rb";
			n = n.split(",");
			for (var o = 0, r = n.length; r > o; o++) {
				var a = n[o],
					s = this._createDiv(this.parent);
				(s.type = "handle"),
					(s.name = a),
					(s.style.position = "absolute"),
					(s.style.backgroundColor = "#FFF"),
					(s.style.border = "solid 1px #555"),
					(s.style.width = s.style.height = this.handleSize + "px");
				var l;
				(l =
					"lt" == a || "rb" == a
						? "nwse-resize"
						: "rt" == a || "lb" == a
						? "nesw-resize"
						: "t" == a || "b" == a
						? "ns-resize"
						: "ew-resize"),
					(s.style.cursor = l),
					(this[n[o]] = s);
			}
			this.interaction = new t.DragSupport(this.parent, this);
		}
		function n() {
			var t = e("<div/>")
				.html(r)
				.contents();
			(this.html = t = t[0]),
				document.body.appendChild(this.html),
				t.addEventListener(
					"mousedown",
					function(e) {
						e.target == t && this.destroy();
					}.bind(this),
					!1
				);
			var i = this._getChild(".graph-export-panel__export_scale"),
				n = this._getChild(".graph-export-panel__export_scale_label");
			(i.onchange = function() {
				(n.textContent = this.scale = i.value), this.updateOutputSize();
			}.bind(this)),
				(this.export_scale = i);
			var o = function(t) {
					var e = this.exportImageInfo();
					if (e) {
						var i = e.canvas,
							n = this.graph.name || "graph";
						i.toBlob(function(e) {
							t(e, n + ".png");
						}, "image/png");
					}
				},
				a = function(t) {
					var e = this.exportImageInfo();
					if (e) {
						var i = window.open(),
							n = i.document;
						n.title = this.graph.name || "";
						var o = n.createElement("img");
						if (
							((o.src = e.data),
							(n.body.style.textAlign = "center"),
							(n.body.style.margin = "0px"),
							n.body.appendChild(o),
							t === !0)
						) {
							var r = n.createElement("style");
							r.setAttribute("type", "text/css"), r.setAttribute("media", "print");
							var a = "img {max-width: 100%; max-height: 100%;}";
							this.clipBounds.width / this.clipBounds.height > 1.2 && (a += "\n @page { size: landscape; }"),
								r.appendChild(document.createTextNode(a)),
								n.head.appendChild(r),
								(o.style.maxWidth = "100%"),
								(o.style.maxHeight = "100%"),
								setTimeout(function() {
									i.print(),
										(i.onfocus = function() {
											i.close();
										});
								}, 100);
						}
					}
				},
				s = this._getChild(".graph-export-panel__export_submit");
			s.onclick = window.saveAs && HTMLCanvasElement.prototype.toBlob ? o.bind(this, window.saveAs) : a.bind(this);
			var l = this._getChild(".graph-export-panel__print_submit");
			l.onclick = a.bind(this, !0);
		}
		function o(t) {
			a || (a = new n()), a.show(t);
		}
		var r =
			'<div class="graph-export-panel modal fade">  <div class="modal-dialog">  <div class="modal-content">  <div class="modal-body">  <h3 style="text-align: center;">图片导出预览</h3>  <div>  <label>画布大小</label>  <span class ="graph-export-panel__canvas_size"></span>  </div>  <div style="text-align: center;" title="双击选择全画布范围">  <div class ="graph-export-panel__export_canvas" style="position: relative; display: inline-block;">  </div>  </div>  <div>  <label>导出范围</label>  <span class ="graph-export-panel__export_bounds"></span>  </div>  <div>  <label>缩放比例: <input class ="graph-export-panel__export_scale" type="range" value="1" step="0.2" min="0.2" max="3"><span class ="graph-export-panel__export_scale_label">1</span></label>  </div>  <div>  <label>输出大小: </label><span class ="graph-export-panel__export_size"></span>  </div>  <div style="text-align: right">  <button type="submit" class="btn btn-primary graph-export-panel__export_submit">导出</button>  <button type="submit" class="btn btn-primary graph-export-panel__print_submit">打印</button>  </div>  </div>  </div>  </div>  </div>';
		(i.prototype = {
			destroy: function() {
				this.interaction.destroy();
			},
			update: function(e, i) {
				(this.wholeBounds = new t.Rect(0, 0, e, i)), this._setBounds(this.wholeBounds.clone());
			},
			ondblclick: function() {
				return this._bounds.equals(this.wholeBounds)
					? (this.oldBounds ||
							(this.oldBounds = this.wholeBounds.clone().grow(-this.wholeBounds.height / 5, -this.wholeBounds.width / 5)),
					  void this._setBounds(this.oldBounds, !0))
					: void this._setBounds(this.wholeBounds.clone(), !0);
			},
			startdrag: function(t) {
				t.target.type && (this.dragItem = t.target);
			},
			ondrag: function(e) {
				if (this.dragItem) {
					t.stopEvent(e);
					var i = e.dx,
						n = e.dy;
					if ("border" == this.dragItem.type) this._bounds.offset(i, n), this._setBounds(this._bounds, !0);
					else if ("handle" == this.dragItem.type) {
						var o = this.dragItem.name;
						"l" == o[0] ? ((this._bounds.x += i), (this._bounds.width -= i)) : "r" == o[0] && (this._bounds.width += i),
							"t" == o[o.length - 1]
								? ((this._bounds.y += n), (this._bounds.height -= n))
								: "b" == o[o.length - 1] && (this._bounds.height += n),
							this._setBounds(this._bounds, !0);
					}
				}
			},
			enddrag: function() {
				this.dragItem &&
					((this.dragItem = !1),
					this._bounds.width < 0
						? ((this._bounds.x += this._bounds.width), (this._bounds.width = -this._bounds.width))
						: 0 == this._bounds.width && (this._bounds.width = 1),
					this._bounds.height < 0
						? ((this._bounds.y += this._bounds.height), (this._bounds.height = -this._bounds.height))
						: 0 == this._bounds.height && (this._bounds.height = 1),
					this._bounds.width > this.wholeBounds.width && (this._bounds.width = this.wholeBounds.width),
					this._bounds.height > this.wholeBounds.height && (this._bounds.height = this.wholeBounds.height),
					this._bounds.x < 0 && (this._bounds.x = 0),
					this._bounds.y < 0 && (this._bounds.y = 0),
					this._bounds.right > this.wholeBounds.width && (this._bounds.x -= this._bounds.right - this.wholeBounds.width),
					this._bounds.bottom > this.wholeBounds.height && (this._bounds.y -= this._bounds.bottom - this.wholeBounds.height),
					this._setBounds(this._bounds, !0));
			},
			_createDiv: function(t) {
				var e = document.createElement("div");
				return t.appendChild(e), e;
			},
			_setHandleLocation: function(t, e, i) {
				(t.style.left = e - this.handleSize / 2 + "px"), (t.style.top = i - this.handleSize / 2 + "px");
			},
			_setBounds: function(t) {
				t.equals(this.wholeBounds) || (this.oldBounds = t),
					(this._bounds = t),
					(t = t.clone()),
					(t.width += 1),
					(t.height += 1),
					(this.boundsDiv.style.left = t.x + "px"),
					(this.boundsDiv.style.top = t.y + "px"),
					(this.boundsDiv.style.width = t.width + "px"),
					(this.boundsDiv.style.height = t.height + "px"),
					this._setHandleLocation(this.lt, t.x, t.y),
					this._setHandleLocation(this.t, t.cx, t.y),
					this._setHandleLocation(this.rt, t.right, t.y),
					this._setHandleLocation(this.l, t.x, t.cy),
					this._setHandleLocation(this.r, t.right, t.cy),
					this._setHandleLocation(this.lb, t.x, t.bottom),
					this._setHandleLocation(this.b, t.cx, t.bottom),
					this._setHandleLocation(this.rb, t.right, t.bottom),
					this.onBoundsChange && this.onBoundsChange(this._bounds);
			},
		}),
			Object.defineProperties(i.prototype, {
				bounds: {
					get: function() {
						return this._bounds;
					},
					set: function(t) {
						this._setBounds(t);
					},
				},
			}),
			(n.prototype = {
				canvas: null,
				html: null,
				exportImageInfo: function(e) {
					var e = this.graph;
					if (e) {
						var i = this.export_scale.value,
							n = this.imageInfo.scale,
							o = new t.Rect(
								this.clipBounds.x / n,
								this.clipBounds.y / n,
								this.clipBounds.width / n,
								this.clipBounds.height / n
							);
						o.offset(this.bounds.x, this.bounds.y);
						var r = e.exportImage(i, o);
						if (r && r.data) return r;
					}
				},
				_getChild: function(t) {
					return e(this.html).find(t)[0];
				},
				initCanvas: function() {
					var e = this._getChild(".graph-export-panel__export_canvas");
					e.innerHTML = "";
					var n = t.createCanvas(!0);
					e.appendChild(n), (this.canvas = n);
					var o,
						r = this._getChild(".graph-export-panel__export_bounds"),
						a = this._getChild(".graph-export-panel__export_size"),
						s = function() {
							var t = this.canvas,
								e = t.g,
								i = t.ratio || 1;
							e.save(),
								e.clearRect(0, 0, t.width, t.height),
								e.drawImage(this.imageInfo.canvas, 0, 0),
								e.beginPath(),
								e.moveTo(0, 0),
								e.lineTo(t.width, 0),
								e.lineTo(t.width, t.height),
								e.lineTo(0, t.height),
								e.lineTo(0, 0);
							var n = o.x * i,
								r = o.y * i,
								a = o.width * i,
								s = o.height * i;
							e.moveTo(n, r),
								e.lineTo(n, r + s),
								e.lineTo(n + a, r + s),
								e.lineTo(n + a, r),
								e.closePath(),
								(e.fillStyle = "rgba(0, 0, 0, 0.3)"),
								e.fill(),
								e.restore();
						},
						l = function(t) {
							(o = t), (this.clipBounds = o), s.call(this);
							var e = (o.width / this.imageInfo.scale) | 0,
								i = (o.height / this.imageInfo.scale) | 0;
							(r.textContent =
								((o.x / this.imageInfo.scale) | 0) + ", " + ((o.y / this.imageInfo.scale) | 0) + ", " + e + ", " + i),
								this.updateOutputSize();
						};
					this.updateOutputSize = function() {
						var t = this._getChild(".graph-export-panel__export_scale"),
							e = t.value,
							i = ((o.width / this.imageInfo.scale) * e) | 0,
							n = ((o.height / this.imageInfo.scale) * e) | 0,
							r = i + " X " + n;
						i * n > 12e6 && (r += "<span style='color: #F66;'>图幅太大，导出时可能出现内存不足</span>"), (a.innerHTML = r);
					};
					var h = new i(n.parentNode, l.bind(this));
					this.update = function() {
						var t = this.canvas.ratio || 1,
							e = this.imageInfo.width / t,
							i = this.imageInfo.height / t;
						this.canvas.setSize(e, i), h.update(e, i);
					};
				},
				destroy: function() {
					(this.graph = null), (this.imageInfo = null), (this.clipBounds = null), (this.bounds = null);
				},
				show: function(t) {
					e(this.html).modal("show"), (this.graph = t);
					var i = t.bounds;
					this.bounds = i;
					var n = this._getChild(".graph-export-panel__canvas_size");
					n.textContent = (0 | i.width) + " X " + (0 | i.height);
					var o,
						r = Math.min(500, screen.width / 1.3);
					(o = i.width > i.height ? Math.min(1, r / i.width) : Math.min(1, r / i.height)),
						this.canvas || this.initCanvas(),
						(this.imageInfo = t.exportImage(o * this.canvas.ratio)),
						(this.imageInfo.scale = o),
						this.update();
				},
			});
		var a;
		t.showExportPanel = o;
	})(Q, jQuery),
	(function(t, e) {
		function i(t, e, i, o, r) {
			var a = document.createElement("div");
			(a.className = o ? "btn-group-vertical" : "btn-group"), r && a.setAttribute("data-toggle", "buttons");
			for (var s = 0, l = t.length; l > s; s++) !t[s].type && r && (t[s].type = "radio"), (a.appendChild(n(t[s], i)).info = t[s]);
			e.appendChild(a);
		}
		function n(i, n) {
			if ("search" == i.type) {
				var o = document.createElement("div");
				(o.style.display = "inline-block"),
					(o.style.verticalAlign = "middle"),
					(o.style.width = "170px"),
					(o.innerHTML =
						'<div class="input-group input-group-sm" >            <input type="text" class="form-control" placeholder="' +
						(i.placeholder || "") +
						'">                <span class="input-group-btn">                    <div class="btn btn-default" type="button"></div>                </span>            </div>');
				var r = o.getElementsByTagName("input")[0];
				i.id && (r.id = i.id);
				var a = e(o).find(".btn")[0];
				if (i.iconClass) {
					var s = document.createElement("div");
					e(s).addClass(i.iconClass), a.appendChild(s);
				} else i.name && a.appendChild(document.createTextNode(" " + i.name));
				if (((i.input = r), i.search)) {
					var l = function() {
							i.searchInfo = null;
						},
						h = function(t) {
							var e = r.value;
							if (!e) return void l();
							if (!i.searchInfo || i.searchInfo.value != e) {
								var n = i.search(e, i);
								if (!n || !n.length) return void l();
								i.searchInfo = { value: e, result: n };
							}
							u(t);
						},
						u = function(t) {
							if (i.select instanceof Function && i.searchInfo && i.searchInfo.result && i.searchInfo.result.length) {
								var e = i.searchInfo,
									n = i.searchInfo.result;
								if (1 == n.length) return void i.select(n[0], 0);
								void 0 === e.index
									? (e.index = 0)
									: ((e.index += t ? -1 : 1), e.index < 0 && (e.index += n.length), (e.index %= n.length)),
									i.select(n[e.index], e.index) === !1 && ((i.searchInfo = null), h());
							}
						};
					(r.onkeydown = function(e) {
						return 27 == e.keyCode ? (l(), (r.value = ""), void t.stopEvent(e)) : void (13 == e.keyCode && h(e.shiftKey));
					}),
						(a.onclick = function() {
							h();
						});
				}
				return o;
			}
			if ("file" == i.type) {
				var p = document.createElement("span"),
					r = document.createElement("input");
				if (
					((p.className = "file-input btn btn-default btn-sm btn-file"),
					r.setAttribute("type", "file"),
					(r.className = "btn-file"),
					i.action &&
						(r.onchange = function(t) {
							var o = e(this),
								r = o.get(0).files;
							(p = o
								.val()
								.replace(/\\/g, "/")
								.replace(/.*\//, "")),
								r.length && i.action.call(n, r, p, t);
						}),
					p.appendChild(r),
					i.icon)
				) {
					var s = document.createElement("img");
					(s.src = i.icon), p.appendChild(s);
				} else if (i.iconClass) {
					var s = document.createElement("div");
					e(s).addClass(i.iconClass), p.appendChild(s);
				} else i.name && p.appendChild(document.createTextNode(" " + i.name));
				return i.name && p.setAttribute("title", i.name), p;
			}
			if ("input" == i.type) {
				var o = document.createElement("div");
				(o.style.display = "inline-block"),
					(o.style.verticalAlign = "middle"),
					(o.innerHTML =
						'<div class="input-group input-group-sm" style="width: 150px;">            <input type="text" class="form-control">                <span class="input-group-btn">                    <button class="btn btn-default" type="button"></button>                </span>            </div>');
				var r = o.getElementsByTagName("input")[0],
					a = o.getElementsByTagName("button")[0];
				return (
					(a.innerHTML = i.name),
					(i.input = r),
					i.action &&
						(a.onclick = function(t) {
							i.action.call(n || window.graph, t, i);
						}),
					o
				);
			}
			if ("select" == i.type) {
				var o = document.createElement("select");
				o.className = "form-control";
				var d = i.options;
				return (
					d.forEach(function(t) {
						var e = document.createElement("option");
						(e.innerHTML = t), (e.value = t), o.appendChild(e);
					}),
					(o.value = i.value),
					i.action &&
						(o.onValueChange = function(t) {
							i.action.call(n || window.graph, t, i);
						}),
					o
				);
			}
			if (i.type) {
				var p = document.createElement("label"),
					a = document.createElement("input");
				(i.input = a),
					a.setAttribute("type", i.type),
					p.appendChild(a),
					i.selected && (a.setAttribute("checked", "checked"), "radio" == i.type && (p.className += "active"));
			} else var p = document.createElement("div");
			if (((p.className += "btn btn-default btn-sm"), i.icon)) {
				var s = document.createElement("img");
				(s.src = i.icon), p.appendChild(s);
			} else if (i.iconClass) {
				var s = document.createElement("div");
				e(s).addClass(i.iconClass), p.appendChild(s);
			} else i.name && p.appendChild(document.createTextNode(" " + i.name));
			return (
				i.name && p.setAttribute("title", i.name),
				i.action &&
					((a || p).onclick = function(t) {
						i.action.call(n || window.graph, t, i);
					}),
				p
			);
		}
		function o(o, r, a) {
			function s() {
				return r.graph;
			}
			function l(t, e) {
				if (t == e) return !0;
				if (!t || !e) return !1;
				for (var i in t) if (t[i] != e[i]) return !1;
				return !0;
			}
			function h() {
				var i = s(),
					n = i ? i.interactionMode : null,
					o = i ? i.interactionProperties : null;
				e(r)
					.find(".btn")
					.each(function(e, i) {
						return i.info && i.info.interactionMode
							? i.info.interactionMode != n || (o && !l(o, i.info))
								? void t.removeClass(i, "active")
								: void t.appendClass(i, "active")
							: void 0;
					});
			}
			function u(t) {
				"interactionMode" == t.kind && h();
			}
			function p(t, e, i) {
				var n = s();
				n && ((n.interactionMode = e.value), (n.interactionProperties = i || e));
			}
			function d(e, o, r, a, s) {
				for (var l in e) {
					var h = e[l];
					t.isArray(h)
						? (h.forEach(function(t) {
								t.interactionMode && ((t.value = t.interactionMode), (t.action = p));
						  }),
						  i(h, o, r, a, s))
						: (h.interactionMode && ((h.value = h.interactionMode), (h.action = p)), (o.appendChild(n(h, r)).info = h));
				}
			}
			r.addEventListener(
				"click",
				function() {
					h();
				},
				!1
			),
				(r.setGraph = function(t) {
					var e = this.graph;
					e && e.propertyChangeDispatcher.removeListener(u, this),
						(this.graph = t),
						h(),
						t && t.propertyChangeDispatcher.addListener(u, this);
				});
			var c = {
				interactionModes: [
					{
						name: "默认模式",
						interactionMode: t.Consts.INTERACTION_MODE_DEFAULT,
						selected: !0,
						iconClass: "q-icon toolbar-default",
					},
					{
						name: "框选模式",
						interactionMode: t.Consts.INTERACTION_MODE_SELECTION,
						iconClass: "q-icon toolbar-rectangle_selection",
					},
					{ name: "浏览模式", interactionMode: t.Consts.INTERACTION_MODE_VIEW, iconClass: "q-icon toolbar-pan" },
				],
				zoom: [
					{
						name: "放大",
						iconClass: "q-icon toolbar-zoomin",
						action: function() {
							s().zoomIn();
						},
					},
					{
						name: "缩小",
						iconClass: "q-icon toolbar-zoomout",
						action: function() {
							s().zoomOut();
						},
					},
					{
						name: "1:1",
						iconClass: "q-icon toolbar-zoomreset",
						action: function() {
							s().scale = 1;
						},
					},
					{
						name: "纵览",
						iconClass: "q-icon toolbar-overview",
						action: function() {
							s().zoomToOverview();
						},
					},
				],
				editor: [
					{ name: "创建连线", interactionMode: t.Consts.INTERACTION_MODE_CREATE_EDGE, iconClass: "q-icon toolbar-edge" },
					{
						name: "创建L型连线",
						interactionMode: t.Consts.INTERACTION_MODE_CREATE_SIMPLE_EDGE,
						iconClass: "q-icon toolbar-edge_VH",
						edgeType: t.Consts.EDGE_TYPE_VERTICAL_HORIZONTAL,
					},
					{ name: "创建多边形", interactionMode: t.Consts.INTERACTION_MODE_CREATE_SHAPE, iconClass: "q-icon toolbar-polygon" },
					{ name: "创建线条", interactionMode: t.Consts.INTERACTION_MODE_CREATE_LINE, iconClass: "q-icon toolbar-line" },
				],
				search: {
					name: "Find",
					placeholder: "Name",
					iconClass: "q-icon toolbar-search",
					type: "search",
					id: "search_input",
					search: function(t) {
						var e = [],
							i = new RegExp(t, "i");
						return (
							s().forEach(function(t) {
								t.name && i.test(t.name) && e.push(t.id);
							}),
							e
						);
					},
					select: function(t) {
						if (((t = s().graphModel.getById(t)), !t)) return !1;
						s().setSelection(t), s().sendToTop(t);
						var e = s().getUIBounds(t);
						e && s().centerTo(e.cx, e.cy, Math.max(2, s().scale), !0);
					},
				},
				exportImage: {
					name: "导出图片",
					iconClass: "q-icon toolbar-print",
					action: function() {
						t.showExportPanel(s());
					},
				},
			};
			if (a) for (var f in a) c[f] = a[f];
			return d(c, r, this, !1, !1), r.setGraph(o), r;
		}
		(t.createToolbar = o), (t.createButtonGroup = i), (t.createButton = n);
	})(Q, jQuery),
	!(function(t, e) {
		function i(t) {
			if (!t) return s;
			var e = {};
			for (var i in s) e[i] = s[i];
			for (var i in t) {
				var n = l[i];
				n && (e[n] = t[i]);
			}
			return e;
		}
		function n(t, i) {
			t &&
				(void 0 === i && (i = e(t).hasClass("group--closed")),
				i ? e(t).removeClass("group--closed") : e(t).addClass("group--closed"));
		}
		function o(e) {
			return t.isString(e) || e.draw instanceof Function;
		}
		var r = function(t, i, n, o) {
				var r = document.createElement(n || "div");
				return (r.className = t), e(r).html(o), i && i.appendChild(r), r;
			},
			a = function(t, e, i) {
				if (Array.isArray(t))
					return t.forEach(function(t) {
						e.call(this, t);
					}, i);
				for (var n in t) e.call(i, t[n], n);
			},
			s = { fillColor: "#EEE", lineWidth: 1, strokeStyle: "#2898E0", padding: { left: 1, top: 1, right: 5, bottom: 5 } },
			l = {};
		(l[t.Styles.RENDER_COLOR] = "renderColor"),
			(l[t.Styles.RENDER_COLOR_BLEND_MODE] = "renderColorBlendMode"),
			(l[t.Styles.SHAPE_FILL_COLOR] = "fillColor"),
			(l[t.Styles.SHAPE_STROKE_STYLE] = "strokeStyle"),
			(l[t.Styles.SHAPE_LINE_DASH] = "borderLineDash"),
			(l[t.Styles.SHAPE_LINE_DASH_OFFSET] = "borderLineDashOffset"),
			(l[t.Styles.SHAPE_OUTLINE] = "outline"),
			(l[t.Styles.SHAPE_OUTLINE_STYLE] = "outlineStyle"),
			(l[t.Styles.LINE_CAP] = "lineGap"),
			(l[t.Styles.LINE_JOIN] = "lineJoin"),
			(l[t.Styles.BACKGROUND_COLOR] = "backgroundColor"),
			(l[t.Styles.BACKGROUND_GRADIENT] = "backgroundGradient"),
			(l[t.Styles.BORDER] = "border"),
			(l[t.Styles.BORDER_COLOR] = "borderColor"),
			(l[t.Styles.BORDER_LINE_DASH] = "borderLineDash"),
			(l[t.Styles.BORDER_LINE_DASH_OFFSET] = "borderLineDashOffset");
		var h = function(t) {
				for (var i = t.target.parentNode; i && !e(i).hasClass("group"); ) i = i.parentNode;
				n(i);
			},
			u = function(t, e, i) {
				(this.graph = t), (this.html = e), this.init(i);
			};
		(u.prototype = {
			loadButton: null,
			imageWidth: 40,
			imageHeight: 40,
			loadImageBoxes: function(e) {
				return t.isArray(e)
					? void a(
							e,
							function(t) {
								this.loadImageBox(t);
							},
							this
					  )
					: void this.loadImageBox(e);
			},
			loadImageBox: function(e, i) {
				if ((t.isString(e) && (e = JSON.parse(e)), i)) {
					var n = this.html.getElementsByClassName("group").item(0);
					if (n) return void this.html.insertBefore(this._createGroup(e, e.prefix), n);
				}
				return this.html.appendChild(this._createGroup(e, e.prefix));
			},
			loadImageBoxFile: function(e) {
				e[0] &&
					t.readerSingleFile(
						e[0],
						"json",
						function(t) {
							t && this.loadImageBox(t, !0);
						}.bind(this)
					);
			},
			hideButtonBar: function(t) {
				this.buttonBar.style.display = t ? "" : "none";
			},
			init: function(e) {
				{
					var i = this.html;
					this.graph;
				}
				t.appendClass(i, "graph-editor__toolbox");
				var n = (this.buttonBar = r("graph-editor__toolbox-buttonBar", i)),
					o = (this.loadButton = t.createButton(
						{
							type: "file",
							name: getI18NString("Load Images..."),
							iconClass: "q-icon toolbar-add",
							action: this.loadImageBoxFile.bind(this),
						},
						this
					));
				n.appendChild(o), this.hideButtonBar();
				var a = [
						{ label: "Node", image: "Q-node" },
						{
							type: "Text",
							label: "Text",
							html:
								'<span style="background-color: #2898E0; color:#FFF; padding: 3px 5px;">' +
								getI18NString("Text") +
								"</span>",
							styles: { "label.background.color": "#2898E0", "label.color": "#FFF", "label.padding": new t.Insets(3, 5) },
						},
						{ type: "Group", label: "Group", image: "Q-group" },
						{ label: "SubNetwork", image: "Q-subnetwork", properties: { enableSubNetwork: !0 } },
					],
					s = [
						{ prefix: "Q-", name: "basic.nodes", displayName: getI18NString("Basic Nodes"), images: a },
						{
							prefix: "Q-",
							name: "register.images",
							displayName: getI18NString("Register Images"),
							images: t.getAllImages(),
							close: !0,
						},
						{
							name: "default.shapes",
							displayName: getI18NString("Default Shapes"),
							prefix: "Q-",
							images: t.Shapes.getAllShapes(this.imageWidth, this.imageHeight),
							close: !0,
						},
					];
				this.loadImageBoxes(s), e && this.loadImageBoxes(e), t.Shapes.getShape(t.Consts.SHAPE_CIRCLE, 100, 100);
			},
			_index: 0,
			_getGroup: function(t) {
				return this._groups[t];
			},
			hideDefaultGroups: function() {
				this.hideGroup("basic.nodes"), this.hideGroup("register.images"), this.hideGroup("default.shapes");
			},
			hideGroup: function(t) {
				var e = this._getGroup(t);
				e && (e.style.display = "none");
			},
			showGroup: function(t) {
				var e = this._getGroup(t);
				e && (e.style.display = "");
			},
			_groups: {},
			_createGroup: function(e) {
				function s(e, i, n) {
					if (!e) return e;
					if (t.isString(e)) return u + e;
					if (e.draw instanceof Function) {
						if (n) return e;
						var o = e.imageName || e.name || i || "drawable-" + this._index++;
						return t.hasImage(o) || t.registerImage(o, e), o;
					}
					throw new Error("image format error");
				}
				var l = e.name,
					u = e.root || "",
					p = e.images,
					d = e.close,
					c = e.displayName || l,
					f = r("group");
				(f.id = l), (this._groups[l] = f);
				var g = r("group__title", f);
				(g.onclick = h), r(null, g, "span", c), r("q-icon group-expand toolbar-expand", g, "span");
				var m = r("group__items", f),
					v = document.createElement("div");
				if (((v.style.clear = "both"), f.appendChild(v), d && n(f), !p)) return f;
				var y = e.imageWidth || this.imageWidth,
					_ = e.imageHeight || this.imageHeight,
					b = e.showLabel;
				return (
					a(
						p,
						function(n, a) {
							if ("_classPath" != a && "_className" != a) {
								var l, h;
								o(n)
									? ((h = l = s(n, a)), (n = { image: l }))
									: ((l = n.image = s(n.image, a)), (h = n.icon ? s(n.icon, a, !0) : l));
								var u, p;
								if (n.html) {
									var u = document.createElement("div");
									(u.style.width = y + "px"),
										(u.style.height = _ + "px"),
										(u.style.lineHeight = _ + "px"),
										(u.style.overflow = "hidden"),
										(u.innerHTML = n.html);
								} else {
									if (!h) return;
									(u = t.createCanvas(y, _, !0)),
										t.drawImage(h, u, i(n.styles)),
										e.size && (n.properties || (n.properties = {}), n.properties.size || (n.properties.size = e.size)),
										(p = l);
								}
								(p = n.tooltip || n.label || p || a), u.setAttribute("title", p);
								var d = r("group__item", m);
								if ((t.appendDNDInfo(u, n), d.appendChild(u), n.br)) {
									var c = document.createElement("br");
									m.appendChild(c);
								}
								if (p && (b || n.showLabel)) {
									var f = p,
										g = 10;
									f.length > g && (f = "..." + f.substring(f.length - g + 2));
									var v = document.createElement("div");
									(v.style.lineHeight = "1em"),
										(v.style.overFlow = "hide"),
										(v.style.marginTop = "0px"),
										(v.textContent = f),
										d.appendChild(v);
								}
							}
						},
						this
					),
					f
				);
			},
		}),
			(t.ToolBox = u);
	})(Q, jQuery),
	!(function(t, e) {
		function i(t) {
			if (!t) return s;
			var e = {};
			for (var i in s) e[i] = s[i];
			for (var i in t) {
				var n = l[i];
				n && (e[n] = t[i]);
			}
			return e;
		}
		function n(t, i) {
			t &&
				(void 0 === i && (i = e(t).hasClass("group--closed")),
				i ? e(t).removeClass("group--closed") : e(t).addClass("group--closed"));
		}
		function o(e) {
			return t.isString(e) || e.draw instanceof Function;
		}
		var r = function(t, i, n, o) {
				var r = document.createElement(n || "div");
				return (r.className = t), e(r).html(o), i && i.appendChild(r), r;
			},
			a = function(t, e, i) {
				if (Array.isArray(t))
					return t.forEach(function(t) {
						e.call(this, t);
					}, i);
				for (var n in t) e.call(i, t[n], n);
			},
			s = { fillColor: "#EEE", lineWidth: 1, strokeStyle: "#2898E0", padding: { left: 1, top: 1, right: 5, bottom: 5 } },
			l = {};
		(l[t.Styles.RENDER_COLOR] = "renderColor"),
			(l[t.Styles.RENDER_COLOR_BLEND_MODE] = "renderColorBlendMode"),
			(l[t.Styles.SHAPE_FILL_COLOR] = "fillColor"),
			(l[t.Styles.SHAPE_STROKE_STYLE] = "strokeStyle"),
			(l[t.Styles.SHAPE_LINE_DASH] = "borderLineDash"),
			(l[t.Styles.SHAPE_LINE_DASH_OFFSET] = "borderLineDashOffset"),
			(l[t.Styles.SHAPE_OUTLINE] = "outline"),
			(l[t.Styles.SHAPE_OUTLINE_STYLE] = "outlineStyle"),
			(l[t.Styles.LINE_CAP] = "lineGap"),
			(l[t.Styles.LINE_JOIN] = "lineJoin"),
			(l[t.Styles.BACKGROUND_COLOR] = "backgroundColor"),
			(l[t.Styles.BACKGROUND_GRADIENT] = "backgroundGradient"),
			(l[t.Styles.BORDER] = "border"),
			(l[t.Styles.BORDER_COLOR] = "borderColor"),
			(l[t.Styles.BORDER_LINE_DASH] = "borderLineDash"),
			(l[t.Styles.BORDER_LINE_DASH_OFFSET] = "borderLineDashOffset");
		var h = function(t) {
				for (var i = t.target.parentNode; i && !e(i).hasClass("group"); ) i = i.parentNode;
				n(i);
			},
			u = function(t, e, i) {
				(this.graph = t), (this.html = e), this.init(i);
			};
		(u.prototype = {
			loadButton: null,
			imageWidth: 40,
			imageHeight: 40,
			loadImageBoxes: function(e) {
				return t.isArray(e)
					? void a(
							e,
							function(t) {
								this.loadImageBox(t);
							},
							this
					  )
					: void this.loadImageBox(e);
			},
			loadImageBox: function(e, i) {
				if ((t.isString(e) && (e = JSON.parse(e)), i)) {
					var n = this.html.getElementsByClassName("group").item(0);
					if (n) return void this.html.insertBefore(this._createGroup(e, e.prefix), n);
				}
				return this.html.appendChild(this._createGroup(e, e.prefix));
			},
			loadImageBoxFile: function(e) {
				e[0] &&
					t.readerSingleFile(
						e[0],
						"json",
						function(t) {
							t && this.loadImageBox(t, !0);
						}.bind(this)
					);
			},
			hideButtonBar: function(t) {
				this.buttonBar.style.display = t ? "" : "none";
			},
			init: function(e) {
				{
					var i = this.html;
					this.graph;
				}
				t.appendClass(i, "graph-editor__toolbox");
				var n = (this.buttonBar = r("graph-editor__toolbox-buttonBar", i)),
					o = (this.loadButton = t.createButton(
						{
							type: "file",
							name: getI18NString("Load Images..."),
							iconClass: "q-icon toolbar-add",
							action: this.loadImageBoxFile.bind(this),
						},
						this
					));
				n.appendChild(o), this.hideButtonBar();
				var a = [
						{ label: "Node", image: "Q-node" },
						{
							type: "Text",
							label: "Text",
							html:
								'<span style="background-color: #2898E0; color:#FFF; padding: 3px 5px;">' +
								getI18NString("Text") +
								"</span>",
							styles: { "label.background.color": "#2898E0", "label.color": "#FFF", "label.padding": new t.Insets(3, 5) },
						},
						{ type: "Group", label: "Group", image: "Q-group" },
						{ label: "SubNetwork", image: "Q-subnetwork", properties: { enableSubNetwork: !0 } },
					],
					s = [
						{ prefix: "Q-", name: "basic.nodes", displayName: getI18NString("Basic Nodes"), images: a },
						{
							prefix: "Q-",
							name: "register.images",
							displayName: getI18NString("Register Images"),
							images: t.getAllImages(),
							close: !0,
						},
						{
							name: "default.shapes",
							displayName: getI18NString("Default Shapes"),
							prefix: "Q-",
							images: t.Shapes.getAllShapes(this.imageWidth, this.imageHeight),
							close: !0,
						},
					];
				this.loadImageBoxes(s), e && this.loadImageBoxes(e), t.Shapes.getShape(t.Consts.SHAPE_CIRCLE, 100, 100);
			},
			_index: 0,
			_getGroup: function(t) {
				return this._groups[t];
			},
			hideDefaultGroups: function() {
				this.hideGroup("basic.nodes"), this.hideGroup("register.images"), this.hideGroup("default.shapes");
			},
			hideGroup: function(t) {
				var e = this._getGroup(t);
				e && (e.style.display = "none");
			},
			showGroup: function(t) {
				var e = this._getGroup(t);
				e && (e.style.display = "");
			},
			_groups: {},
			_createGroup: function(e) {
				function s(e, i, n) {
					if (!e) return e;
					if (t.isString(e)) return u + e;
					if (e.draw instanceof Function) {
						if (n) return e;
						var o = e.imageName || e.name || i || "drawable-" + this._index++;
						return t.hasImage(o) || t.registerImage(o, e), o;
					}
					throw new Error("image format error");
				}
				var l = e.name,
					u = e.root || "",
					p = e.images,
					d = e.close,
					c = e.displayName || l,
					f = r("group");
				(f.id = l), (this._groups[l] = f);
				var g = r("group__title", f);
				(g.onclick = h), r(null, g, "span", c), r("q-icon group-expand toolbar-expand", g, "span");
				var m = r("group__items", f),
					v = document.createElement("div");
				if (((v.style.clear = "both"), f.appendChild(v), d && n(f), !p)) return f;
				var y = e.imageWidth || this.imageWidth,
					_ = e.imageHeight || this.imageHeight,
					b = e.showLabel;
				return (
					a(
						p,
						function(n, a) {
							if ("_classPath" != a && "_className" != a) {
								var l, h;
								o(n)
									? ((h = l = s(n, a)), (n = { image: l }))
									: ((l = n.image = s(n.image, a)), (h = n.icon ? s(n.icon, a, !0) : l));
								var u, p;
								if (n.html) {
									var u = document.createElement("div");
									(u.style.width = y + "px"),
										(u.style.height = _ + "px"),
										(u.style.lineHeight = _ + "px"),
										(u.style.overflow = "hidden"),
										(u.innerHTML = n.html);
								} else {
									if (!h) return;
									(u = t.createCanvas(y, _, !0)),
										t.drawImage(h, u, i(n.styles)),
										e.size && (n.properties || (n.properties = {}), n.properties.size || (n.properties.size = e.size)),
										(p = l);
								}
								(p = n.tooltip || n.label || p || a), u.setAttribute("title", p);
								var d = r("group__item", m);
								if ((t.appendDNDInfo(u, n), d.appendChild(u), n.br)) {
									var c = document.createElement("br");
									m.appendChild(c);
								}
								if (p && (b || n.showLabel)) {
									var f = p,
										g = 10;
									f.length > g && (f = "..." + f.substring(f.length - g + 2));
									var v = document.createElement("div");
									(v.style.lineHeight = "1em"),
										(v.style.overFlow = "hide"),
										(v.style.marginTop = "0px"),
										(v.textContent = f),
										d.appendChild(v);
								}
							}
						},
						this
					),
					f
				);
			},
		}),
			(t.ToolBox = u);
	})(Q, jQuery),
	(function(t) {
		function e(t, i) {
			(t.zIndex = i),
				t.forEachChild(function(t) {
					e(t, i);
				});
		}
		function i(e, i, n) {
			var o = document.documentElement,
				r = new t.Rect(window.pageXOffset, window.pageYOffset, o.clientWidth - 2, o.clientHeight - 2),
				a = e.offsetWidth,
				s = e.offsetHeight;
			i + a > r.x + r.width && (i = r.x + r.width - a),
				n + s > r.y + r.height && (n = r.y + r.height - s),
				i < r.x && (i = r.x),
				n < r.y && (n = r.y),
				(e.style.left = i + "px"),
				(e.style.top = n + "px");
		}
		function n(t, e) {
			for (var i = e.parentNode; null != i; ) {
				if (i == t) return !0;
				i = i.parentNode;
			}
			return !1;
		}
		function o(t) {
			return t.touches && t.touches.length && (t = t.touches[0]), { x: t.pageX, y: t.pageY };
		}
		function r(e, i) {
			var n = i.popupmenu,
				r = o(e),
				a = r.x,
				s = r.y,
				l = n.getMenuItems(i, i.getElement(e), e);
			l && ((n.items = l), n.showAt(a, s), t.stopEvent(e));
		}
		var a = function(t) {
				this.items = t || [];
			},
			s = "dropdown-menu";
		(a.Separator = "divider"),
			(a.prototype = {
				dom: null,
				_invalidateFlag: !0,
				add: function(t) {
					this.items.push(t), (this._invalidateFlag = !0);
				},
				addSeparator: function() {
					this.add(a.Separator);
				},
				showAt: function(t, e) {
					return this.items && this.items.length
						? (this._invalidateFlag && this.render(),
						  (this.dom.style.display = "block"),
						  document.body.appendChild(this.dom),
						  void i(this.dom, t, e))
						: !1;
				},
				hide: function() {
					this.dom && this.dom.parentNode && this.dom.parentNode.removeChild(this.dom);
				},
				isShowing: function() {
					return null !== this.dom.parentNode;
				},
				render: function() {
					if (((this._invalidateFlag = !1), this.dom)) this.dom.innerHTML = "";
					else {
						(this.dom = document.createElement("ul")), this.dom.setAttribute("role", "menu"), (this.dom.className = s);
						var e = t.isTouchSupport ? "touchstart" : "mousedown";
						this.stopEditWhenClickOnWindow ||
							(this.stopEditWhenClickOnWindow = function(t) {
								this.isShowing() && !n(this.dom, t.target) && this.hide();
							}.bind(this)),
							window.addEventListener("mousedown", this.stopEditWhenClickOnWindow, !0),
							this.dom.addEventListener(
								e,
								function(e) {
									t.stopEvent(e);
								},
								!1
							);
					}
					for (var i = 0, o = this.items.length; o > i; i++) {
						var r = this.renderItem(this.items[i]);
						this.dom.appendChild(r);
					}
				},
				html2Escape: function(t) {
					return t.replace(/[<>&"]/g, function(t) {
						return { "<": "&lt;", ">": "&gt;", "&": "&amp;", '"': "&quot;" }[t];
					});
				},
				renderItem: function(e) {
					var i = document.createElement("li");
					if ((i.setAttribute("role", "presentation"), e == a.Separator))
						return (i.className = a.Separator), (i.innerHTML = " "), i;
					if (t.isString(e))
						return (i.innerHTML = '<a role="menuitem" tabindex="-1" href="#">' + this.html2Escape(e) + "</a>"), i;
					e.selected &&
						((i.style.backgroundPosition = "3px 5px"),
						(i.style.backgroundRepeat = "no-repeat"),
						(i.style.backgroundImage =
							"url('')"));
					var n = document.createElement("a");
					if (
						(n.setAttribute("role", "menuitem"),
						n.setAttribute("tabindex", "-1"),
						n.setAttribute("href", "javascript:void(0)"),
						i.appendChild(n),
						e.html)
					)
						n.innerHTML = e.html;
					else {
						var o = e.text || e.name;
						o && (n.innerHTML = this.html2Escape(o));
					}
					var r = e.className;
					r && (i.className = r);
					var s = e.action,
						l = this,
						h = function(i) {
							s && s.call(e.scope, i, e),
								t.isIOS || i.target.focus(),
								setTimeout(function() {
									l.hide();
								}, 100);
						};
					return t.isTouchSupport ? (n.ontouchstart = h) : (i.onclick = h), i;
				},
				getMenuItems: function(i, n) {
					var o = [];
					if (n) {
						var r = n instanceof t.ShapeNode,
							a = (n instanceof t.Group, !r && n instanceof t.Node, n instanceof t.Edge);
						if (
							(o.push({
								text: getI18NString("Rename"),
								action: function() {
									t.prompt(getI18NString("Input Element Name"), n.name || "", function(t) {
										null !== t && (n.name = t);
									});
								},
							}),
							a)
						) {
							var s = n.getStyle(t.Styles.EDGE_LINE_DASH) || t.DefaultStyles[t.Styles.EDGE_LINE_DASH];
							o.push({
								text: getI18NString(s ? "Solid Line" : "Dashed Line"),
								action: function() {
									n.setStyle(t.Styles.EDGE_LINE_DASH, s ? null : [5, 3]);
								},
							}),
								o.push({
									text: getI18NString("Line Width"),
									action: function() {
										t.prompt(
											getI18NString("Input Line Width"),
											n.getStyle(t.Styles.EDGE_WIDTH) || t.DefaultStyles[t.Styles.EDGE_WIDTH],
											function(e) {
												null !== e && ((e = parseFloat(e)), n.setStyle(t.Styles.EDGE_WIDTH, e));
											}
										);
									},
								}),
								o.push({
									text: getI18NString("Line Color"),
									action: function() {
										t.prompt(
											getI18NString("Input Line Color"),
											n.getStyle(t.Styles.EDGE_COLOR) || t.DefaultStyles[t.Styles.EDGE_COLOR],
											function(e) {
												null !== e && n.setStyle(t.Styles.EDGE_COLOR, e);
											}
										);
									},
								});
						} else
							n.parent instanceof t.Group &&
								o.push({
									text: getI18NString("Out of Group"),
									action: function() {
										n.parent = null;
									},
								});
						o.push(t.PopupMenu.Separator),
							o.push({
								text: getI18NString("Send to Top"),
								action: function() {
									e(n, 1), i.sendToTop(n), i.invalidate();
								},
							}),
							o.push({
								text: getI18NString("Send to Bottom"),
								action: function() {
									e(n, -1), i.sendToBottom(n), i.invalidate();
								},
							}),
							o.push({
								text: getI18NString("Reset Layer"),
								action: function() {
									e(n, 0), i.invalidate();
								},
							}),
							o.push(t.PopupMenu.Separator);
					}
					o.push({
						text: getI18NString("Clear Graph"),
						action: function() {
							i.clear();
						},
					}),
						o.push(t.PopupMenu.Separator),
						o.push({
							text: getI18NString("Zoom In"),
							action: function(t) {
								var e = i.globalToLocal(t);
								i.zoomIn(e.x, e.y, !0);
							},
						}),
						o.push({
							text: getI18NString("Zoom Out"),
							action: function(t) {
								var e = i.globalToLocal(t);
								i.zoomOut(e.x, e.y, !0);
							},
						}),
						o.push({
							text: getI18NString("1:1"),
							action: function(t) {
								i.globalToLocal(t);
								i.scale = 1;
							},
						}),
						o.push(t.PopupMenu.Separator);
					for (
						var l = i.interactionMode,
							h = [
								{ text: getI18NString("Pan Mode"), value: t.Consts.INTERACTION_MODE_DEFAULT },
								{ text: getI18NString("Rectangle Select"), value: t.Consts.INTERACTION_MODE_SELECTION },
							],
							u = 0,
							p = h.length;
						p > u;
						u++
					) {
						var d = h[u];
						d.value == l && (d.selected = !0),
							(d.action = function(t, e) {
								i.interactionMode = e.value;
							}),
							o.push(d);
					}
					return (
						o.push(t.PopupMenu.Separator),
						o.push({ html: '<a href="http://qunee.com" target="_blank">Qunee - ' + t.version + "</a>" }),
						o
					);
				},
			}),
			Object.defineProperties(a.prototype, {
				items: {
					get: function() {
						return this._items;
					},
					set: function(t) {
						(this._items = t), (this._invalidateFlag = !0);
					},
				},
			});
		var l = {
			onstart: function(t, e) {
				e._popupmenu.hide();
			},
		};
		t.isTouchSupport &&
			(l.onlongpress = function(t, e) {
				r(t, e);
			}),
			Object.defineProperties(t.Graph.prototype, {
				popupmenu: {
					get: function() {
						return this._popupmenu;
					},
					set: function(t) {
						this._popupmenu != t &&
							((this._popupmenu = t),
							this._contextmenuListener ||
								((this._contextmenuListener = l),
								this.addCustomInteraction(this._contextmenuListener),
								(this.html.oncontextmenu = function(t) {
									this.popupmenu && r(t, this);
								}.bind(this))));
					},
				},
			}),
			(t.PopupMenu = a);
	})(Q, jQuery),
	!(function(t) {
		function e(t, e, i, n, o) {
			(this.getter = i), (this.setter = n), (this.scope = o), (this.property = t), this.createHtml(e);
		}
		function i() {
			t.doSuperConstructor(this, i, arguments);
		}
		function n() {
			t.doSuperConstructor(this, n, arguments);
		}
		function o(t) {
			var e = t._classPath || t._tempName;
			return e || (e = t._tempName = "class-" + x++), e;
		}
		function r(t, e, i) {
			var n = o(t);
			return e ? (i[n] = { class: t, properties: {} }) : i[n];
		}
		function a(e, i) {
			return i == t.Consts.PROPERTY_TYPE_STYLE ? "S:" + e : i == t.Consts.PROPERTY_TYPE_CLIENT ? "C:" + e : e;
		}
		function s(t) {
			l(C, t);
		}
		function l(t, e) {
			var i = e.class;
			if (!i) throw new Error("class property can not be null");
			var n = e.properties,
				a = o(i);
			if (!n) return void delete t[a];
			var s = r(i, !0, t);
			(s = a in t ? t[a] : (t[a] = { class: i, properties: {} })), h(e, s.properties);
		}
		function h(e, i) {
			i = i || {};
			var n = e.properties,
				o = e.group || "Element";
			return (
				n.forEach(function(e) {
					var n;
					if (e.style) (e.propertyType = t.Consts.PROPERTY_TYPE_STYLE), (e.name = e.style);
					else if (e.client) (e.propertyType = t.Consts.PROPERTY_TYPE_CLIENT), (e.name = e.client);
					else {
						if (!e.name) return;
						e.propertyType = t.Consts.PROPERTY_TYPE_ACCESSOR;
					}
					var n = (e.key = a(e.name, e.propertyType));
					e.groupName || (e.groupName = o), (i[n] = e);
				}),
				i
			);
		}
		function u(t, e, i) {
			i || (i = C), (e = e || {});
			for (var n in i)
				if (t instanceof i[n].class) {
					var o = i[n].properties;
					for (var r in o) {
						var a = o[r];
						"none" == a.display ? delete e[r] : (e[r] = a);
					}
				}
			return e;
		}
		function p(t) {
			this.properties = t;
			var e = {},
				i = 0;
			for (var n in t) {
				i++;
				var o = t[n].groupName,
					r = e[o];
				r || (r = e[o] = {}), (r[n] = t[n]);
			}
			(this.group = e), (this.length = i);
		}
		function d(e, i, n, o) {
			return o && o != t.Consts.PROPERTY_TYPE_ACCESSOR
				? o == t.Consts.PROPERTY_TYPE_STYLE
					? e.getStyle(i, n)
					: o == t.Consts.PROPERTY_TYPE_CLIENT
					? i.get(n)
					: void 0
				: i[n];
		}
		function c(e, i, n, o) {
			return o && o != t.Consts.PROPERTY_TYPE_ACCESSOR
				? o == t.Consts.PROPERTY_TYPE_STYLE
					? i.setStyle(n, e)
					: o == t.Consts.PROPERTY_TYPE_CLIENT
					? i.set(n, e)
					: void 0
				: (i[n] = e);
		}
		function f(e, i) {
			(this._propertyMap = {}),
				(this._formItems = []),
				(this.html = this.container = i),
				(this.dom = t.createElement({ class: "form-horizontal", parent: i, tagName: "form" })),
				(this.graph = e),
				e.dataPropertyChangeDispatcher.addListener(
					function(t) {
						this.onDataPropertyChange(t);
					}.bind(this)
				),
				e.selectionChangeDispatcher.addListener(
					function() {
						this.datas = this.graph.selectionModel.toDatas();
					}.bind(this)
				);
		}
		function g(t) {
			return 0 | t;
		}
		function m(t, e) {
			return t
				? "point" == e
					? g(t.x) + "," + g(t.y)
					: "size" == e
					? g(t.width) + "," + g(t.height)
					: "degree" == e
					? ("" + (180 * t) / Math.PI) | 0
					: t.toString()
				: t;
		}
		function v(t, e) {
			if ("color" == e && $.colorpicker && $.colorpicker.Color) return new $.colorpicker.Color(t, null, null, "hex", !0).toString();
			if ("position" == e) return O[t];
			if ("number" == e) return parseFloat(t) || 0;
			if ("boolean" == e) return t ? !0 : !1;
			if ("point" != e) {
				if ("size" != e) return "degree" == e ? (parseInt(t) * Math.PI) / 180 : t;
				var i = t.split(",");
				if (2 == i.length) {
					var n = parseFloat(i[0]) || 0,
						o = parseFloat(i[1]) || 0;
					if (n && o) return { width: n, height: o };
				}
			} else {
				var i = t.split(",");
				if (2 == i.length) return { x: parseFloat(i[0] || 0), y: parseFloat(i[1]) || 0 };
			}
		}
		var y = function(t) {
			t = t || {};
			var e = document.createElement(t.tagName || "div");
			return (
				t.class && $(e).addClass(t.class),
				t.parent && t.parent.appendChild(e),
				t.style && e.setAttribute("style", t.style),
				t.css && $(e).css(t.css),
				t.html && $(e).html(t.html),
				e
			);
		};
		(t.createElement = y),
			(e.prototype = {
				_getValue: function() {
					return this.getter.call(this.scope);
				},
				update: function() {
					this.value = this._getValue();
				},
				setValue: function(t) {
					this.input.value = m(t, this.property.type);
				},
				getValue: function() {
					return v(this.input.value, this.property.type);
				},
				createHtml: function(e) {
					var i,
						n = this.property;
					if (Array.isArray(n.options))
						(i = t.createElement({ tagName: "select", class: "form-control", parent: e })),
							n.options.forEach(function(t) {
								var e = document.createElement("option");
								(e.value = t), (e.innerText = t), i.appendChild(e);
							});
					else var i = t.createElement({ tagName: "input", class: "form-control", parent: e });
					(this.input = i),
						n.readonly && i.setAttribute("readonly", "readonly"),
						this.update(),
						$(i).on(
							"input",
							function() {
								this.ajdusting || this.setter.call(this.scope, this);
							}.bind(this)
						);
				},
			}),
			Object.defineProperties(e.prototype, {
				value: {
					get: function() {
						return this.getValue();
					},
					set: function(t) {
						(this.ajdusting = !0), this.setValue(t), (this.ajdusting = !1);
					},
				},
			}),
			(i.prototype = {
				setValue: function(t) {
					t ? this.input.setAttribute("checked", "checked") : this.input.removeAttribute("checked");
				},
				getValue: function() {
					return v(this.input.checked, this.property.type);
				},
				createHtml: function(e) {
					var i = this.property,
						n = t.createElement({ tagName: "input", parent: e });
					n.setAttribute("type", "checkbox"),
						(this.input = n),
						i.readonly && n.setAttribute("readonly", "readonly"),
						this.update(),
						$(n).on(
							"click",
							function() {
								this.ajdusting || this.setter.call(this.scope, this);
							}.bind(this)
						);
				},
			}),
			t.extend(i, e),
			(n.prototype = {
				createHtml: function(e) {
					var i = t.createElement({ tagName: "input", class: "form-control", parent: e });
					t.createElement({ tagName: "span", parent: e, class: "input-group-addon", html: "<i></i>" }),
						(this.input = i),
						this.update(),
						$(e)
							.colorpicker({ container: !0 })
							.on(
								"changeColor",
								function() {
									this.ajdusting || this.setter.call(this.scope, this);
								}.bind(this)
							);
				},
			}),
			t.extend(n, e);
		var _ = [
				{ name: "name", displayName: "Name" },
				{ style: t.Styles.LABEL_FONT_SIZE, type: "number", displayName: "Font Size" },
				{ style: t.Styles.LABEL_COLOR, type: "color", displayName: "Label Color" },
				{ style: t.Styles.RENDER_COLOR, type: "color", displayName: "Render Color" },
				{ style: t.Styles.LABEL_POSITION, displayName: "Label Position" },
				{ style: t.Styles.LABEL_ANCHOR_POSITION, displayName: "Label Anchor Position" },
			],
			b = [
				{ name: "size", type: "size", displayName: "Size" },
				{ name: "location", type: "point", displayName: "Location" },
				{ name: "rotate", type: "number", displayName: "Rotate" },
				{ style: t.Styles.BORDER, type: "number", displayName: "Border" },
				{ style: t.Styles.BORDER_COLOR, type: "color", displayName: "Border Color" },
			],
			S = [
				{ style: t.Styles.SHAPE_FILL_COLOR, type: "color", displayName: "Fill Color" },
				{ style: t.Styles.SHAPE_STROKE_STYLE, type: "color", displayName: "Stroke Color" },
				{ style: t.Styles.SHAPE_STROKE, type: "number", displayName: "Stroke" },
			],
			E = [
				{ name: "angle", type: "degree", displayName: "angle 0-360°" },
				{ style: t.Styles.BORDER, display: "none" },
				{ style: t.Styles.EDGE_WIDTH, type: "number", displayName: "Edge Width" },
				{ style: t.Styles.EDGE_COLOR, type: "color", displayName: "Edge Color" },
				{ style: t.Styles.ARROW_TO, type: "boolean", displayName: "Arrow To" },
			],
			N = [
				{ name: "size", display: "none" },
				{ style: t.Styles.LABEL_SIZE, type: "size", displayName: "Size" },
				{ style: t.Styles.RENDER_COLOR, display: "none" },
				{ style: t.Styles.LABEL_BACKGROUND_COLOR, type: "color", displayName: "Background Color" },
			],
			C = {},
			x = 0;
		s({ class: t.Element, properties: _, group: "Element" }),
			s({ class: t.Node, properties: b, group: "Node" }),
			s({ class: t.Edge, properties: E, group: "Edge" }),
			s({ class: t.Text, properties: N, group: "Text" }),
			s({ class: t.ShapeNode, properties: S, group: "Shape" }),
			(p.prototype = {
				contains: function(t, e) {
					var i = a(t, e);
					return this.properties[i];
				},
				isEmpty: function() {
					return 0 == this.length;
				},
			});
		var w = function(t, o, r, a, s) {
				var l = t.type;
				return "color" == l ? new n(t, o, r, a, s) : "boolean" == l ? new i(t, o, r, a, s) : new e(t, o, r, a, s);
			},
			O = {};
		for (var I in t.Position) {
			var T = t.Position[I];
			"random" != I && T instanceof t.Position && (O[T.toString()] = T);
		}
		(f.prototype = {
			_formItems: null,
			onValueChange: function(t, e) {
				this.setValue(t, e);
			},
			adjusting: !1,
			_containsElement: function(t) {
				for (var e in this.datas) if (e == t) return !0;
			},
			_containsProperty: function(t, e) {
				return this.propertyGroup && this.propertyGroup.contains(t, e);
			},
			_cellEditors: null,
			_getCellEditors: function(t, e) {
				if (this._cellEditors) {
					var i = a(t, e);
					return this._cellEditors[i];
				}
			},
			onDataPropertyChange: function(e) {
				if (!this.adjusting) {
					if (!this.datas || !this.datas.length) return null;
					var i = e.source;
					if (!this._containsElement(i)) {
						var n = this._getCellEditors(e.kind, e.propertyType);
						if (!n) return;
						t.isArray(n) || (n = [n]),
							n.forEach(function(t) {
								t.update();
							});
					}
				}
			},
			clear: function() {
				$(".colorpicker-element").colorpicker("hide"),
					(this.dom.innerHTML = ""),
					(this._formItems = []),
					(this._cellEditors = null),
					this.setVisible(!1);
			},
			setVisible: function(t) {
				var e = t ? "block" : "none";
				this.container ? (this.container.style.display = e) : (this.dom.style.display = e);
			},
			createItem: function(e, i) {
				var n = t.createElement({ class: "form-group", parent: e }),
					o =
						(t.createElement({
							parent: n,
							tagName: "label",
							class: "col-sm-6 control-label font-small",
							html: getI18NString(i.displayName || i.name),
						}),
						t.createElement({ parent: n, class: "input-group input-group-sm col-sm-6" })),
					r = w(
						i,
						o,
						function() {
							return this.getValue(i);
						}.bind(this),
						function(t) {
							this.onValueChange(t.value, i);
						}.bind(this)
					),
					s = a(i.name, i.propertyType);
				this._cellEditors || (this._cellEditors = {});
				var l = this._cellEditors[s];
				return l ? l.push(r) : (this._cellEditors[s] = [r]), n;
			},
			setValue: function(e, i) {
				return this.datas && this.datas.length
					? ((this.adjusting = !0),
					  i.type && "string" != i.type && t.isString(e) && (e = v(e, i.type)),
					  this.datas.forEach(function(t) {
							var n = d(this.graph, t, i.name, i.propertyType);
							n !== e && c(e, t, i.name, i.propertyType);
					  }, this),
					  void (this.adjusting = !1))
					: null;
			},
			getValue: function(t) {
				return this.datas && this.datas.length
					? 1 == this.datas.length
						? d(this.graph, this.datas[0], t.name, t.propertyType) || ""
						: void 0
					: null;
			},
			createItemGroup: function(e, i) {
				var n = t.createElement({ class: "class-group", parent: this.dom });
				t.createElement({ tagName: "h4", parent: n, html: e });
				for (var e in i) this.createItem(n, i[e]);
			},
			register: function(t) {
				l(this._propertyMap, t);
			},
			showDefaultProperties: !0,
			getCustomPropertyDefinitions: function(t) {
				return t.propertyDefinitions;
			},
			getProperties: function(t) {
				var e = {};
				this.showDefaultProperties && u(t, e), this._propertyMap && u(t, e, this._propertyMap);
				var i = this.getCustomPropertyDefinitions(t);
				if (i) {
					var n = h(i);
					for (var o in n) e[o] = n[o];
				}
				return e;
			},
			_getProperties: function(t) {
				var e = this.getProperties(t);
				return new p(e);
			},
			_show: function() {
				var t = this.datas;
				if (t && t.length) {
					this.setVisible(!0), (this.propertyGroup = this._getProperties(t[0]));
					var e = this.propertyGroup.group;
					for (var i in e) this.createItemGroup(i, e[i]);
				}
			},
		}),
			Object.defineProperties(f.prototype, {
				datas: {
					get: function() {
						return this._datas;
					},
					set: function(e) {
						if (this._datas != e) {
							if ((e && !t.isArray(e) && (e = [e]), this.clear(), !e.length)) return void (this._datas = null);
							(this._datas = e), 1 == e.length && this._show();
						}
					},
				},
			}),
			(t.PropertyPane = f),
			(t.PropertyPane.register = s);
	})(Q),
	(GridBackground.prototype = {
		update: function() {
			var t = this.graph,
				e = this.canvas,
				i = this.scaleCanvas;
			t.callLater(function() {
				e.setSize(t.width, t.height), (e.width = e.width), i.setSize(t.width, t.height), (i.width = e.width);
				var n = t.scale,
					o = 50 / n,
					r = (this.currentCell = 10 * (Math.round(o / 10) || 1));
				n = t.scale * e.ratio;
				var a = t.viewportBounds,
					s = e.g;
				s.save(), this._doTransform(s, n, a), s.beginPath();
				var l = a.x,
					h = a.y,
					u = a.right,
					p = a.bottom;
				for (l % r !== 0 && (l -= l % r), h % r !== 0 && (h -= h % r); u > l; ) s.moveTo(l, a.y), s.lineTo(l, p), (l += r);
				for (; p > h; ) s.moveTo(a.x, h), s.lineTo(u, h), (h += r);
				(s.lineWidth = 1 / n),
					(s.strokeStyle = "#CCC"),
					s.stroke(),
					i.g.save(),
					this._doTransform(i.g, n, a),
					this.drawScales(i.g, a, n, i.ratio),
					i.g.restore(),
					s.restore();
			}, this);
		},
		_doTransform: function(t, e, i) {
			t.translate(-e * i.x, -e * i.y), t.scale(e, e);
		},
		drawText: function(t, e, i, n, o, r, a, s) {
			(o = o || 7), t.save();
			var l = 3;
			(o *= l),
				(t.font = "normal " + o + "px helvetica arial"),
				(t.fillStyle = "#555"),
				(t.textAlign = r || "center"),
				(t.textBaseline = a || "top"),
				t.translate(i, n),
				s && t.rotate(s),
				t.scale(1 / l, 1 / l),
				t.fillText(e, 0, 0),
				t.restore();
		},
		drawScales: function(t, e, i, n) {
			t.beginPath();
			var o = (5 * n) / i,
				r = (12 * n) / i;
			t.beginPath();
			var a = e.x;
			for (a = this.currentCell * Math.ceil(a / this.currentCell); a < e.right; )
				t.moveTo(a, e.y), t.lineTo(a, e.y + o + o), this.drawText(t, ("" + a) | 0, a, e.y + o + o, r), (a += this.currentCell);
			var s = e.y;
			for (s = this.currentCell * Math.ceil(s / this.currentCell); s < e.bottom; )
				t.moveTo(e.x, s),
					t.lineTo(e.x + o + o, s),
					this.drawText(t, ("" + s) | 0, e.x + o + o, s, r, "center", "top", -Math.PI / 6),
					(s += this.currentCell);
			(t.lineWidth = 1 / i), (t.strokeStyle = "#000"), t.stroke();
		},
	}),
	(function(t) {
		function e(e, i) {
			(this.html = e),
				(this.canvas = t.createCanvas(!0)),
				this.html.appendChild(this.canvas),
				new t.DragSupport(this.canvas, this),
				this.setGraph(i);
		}
		function i(e, i) {
			e.touches && (e = e.changedTouches && e.changedTouches.length ? e.changedTouches[0] : e.touches[0]);
			var n = i.getBoundingClientRect(),
				o = e.clientX || 0,
				r = e.clientY || 0;
			return (
				t.isTouchSupport &&
					t.isSafari &&
					(window.pageXOffset && o == e.pageX && (o -= window.pageXOffset),
					window.pageYOffset && r == e.pageY && (r -= window.pageYOffset)),
				[o - n.left, r - n.top]
			);
		}
		(e.prototype = {
			canvas: null,
			html: null,
			setGraph: function(t) {
				this.graph != t && (this._uninstall(), (this.graph = t), this._install());
			},
			_install: function() {
				this.graph &&
					(this._onPropertyChanged ||
						((this._onPropertyChanged = function(t) {
							var e = t.kind;
							return "element.bounds" == e
								? void this._invalidateGraph()
								: void (("transform" == e || "viewport" == e) && this.invalidate());
						}.bind(this)),
						(this._onDataChanged = function() {
							this._invalidateGraph();
						}.bind(this))),
					this.graph.propertyChangeDispatcher.addListener(this._onPropertyChanged),
					this.graph.dataPropertyChangeDispatcher.addListener(this._onDataChanged),
					this.graph.listChangeDispatcher.addListener(this._onDataChanged),
					this._invalidateGraph(!0));
			},
			_uninstall: function() {
				this.graph &&
					this._onPropertyChanged &&
					(this.graph.propertyChangeDispatcher.removeListener(this._onPropertyChanged),
					this.graph.dataPropertyChangeDispatcher.removeListener(this._onDataChanged),
					this.graph.listChangeDispatcher.removeListener(this._onDataChanged),
					(this.imageInfo = null),
					(this.bounds = null),
					(this.scale = null));
			},
			_toCanvas: function(t, e) {
				return (t = this.scale * (t - this.bounds.x)), (e = this.scale * (e - this.bounds.y)), [t, e];
			},
			_toGraph: function(t) {
				var e = i(t, this.html),
					n = e[0] / this.scale + this.bounds.x,
					o = e[1] / this.scale + this.bounds.y;
				return [n, o];
			},
			_validateGraph: function() {
				if (((this._invalidateGraphFlag = !1), this.visible)) {
					var e = this.html.clientWidth,
						i = this.html.clientHeight,
						n = new t.Rect();
					n.add(this.graph.bounds);
					var o = Math.min(e / n.width, i / n.height) * this.canvas.ratio;
					(this.imageInfo = this.exportGraphImage(o, n)),
						(this.imageInfo.scale = o),
						(this.imageInfo.bounds = n),
						this.invalidate();
				}
			},
			exportGraphImage: function(t, e) {
				return this.graph.exportImage(t, e);
			},
			_invalidateGraphFlag: !1,
			_invalidateGraph: function(t) {
				!this.graph ||
					(!t && this._invalidateGraphFlag) ||
					((this._invalidateGraphFlag = !0), this.graph.callLater(this._validateGraph, this, t ? 100 : 1e3));
			},
			invalidate: function(t) {
				(t || !this._invalidateFlag) && ((this._invalidateFlag = !0), setTimeout(this.validate.bind(this)));
			},
			validate: function() {
				this._invalidateFlag = !1;
				var e = this.imageInfo;
				if (e) {
					var i = this.graph.viewportBounds;
					if (i.height && i.width) {
						var n = this.canvas,
							o = n.ratio,
							r = n.getContext("2d"),
							a = this.html.clientWidth,
							s = this.html.clientHeight;
						(n.style.width = a + "px"), (n.style.height = s + "px"), (n.width = a * o), (n.height = s * o), r.scale(o, o);
						var l = new t.Rect(e.bounds);
						l.add(i);
						var h = Math.min(a / l.width, s / l.height);
						this.scale = h;
						var u = (a / h - l.width) / 2,
							p = (s / h - l.height) / 2;
						(l.x -= u), (l.y -= p), (l.width = a / h), (l.height = s / h), (this.bounds = l), r.save();
						var d = this._toCanvas(e.bounds.x, e.bounds.y);
						r.translate(d[0], d[1]),
							r.scale(h / e.scale, h / e.scale),
							r.drawImage(this.imageInfo.canvas, 0, 0),
							r.restore(),
							r.beginPath(),
							r.moveTo(0, 0),
							r.lineTo(n.width, 0),
							r.lineTo(n.width, n.height),
							r.lineTo(0, n.height),
							r.lineTo(0, 0),
							(d = this._toCanvas(i.x, i.y));
						var c = d[0],
							f = d[1],
							a = i.width * h,
							s = i.height * h;
						r.moveTo(c, f),
							r.lineTo(c, f + s),
							r.lineTo(c + a, f + s),
							r.lineTo(c + a, f),
							r.closePath(),
							(r.fillStyle = "rgba(30, 30, 30, 0.3)"),
							r.fill(),
							(r.lineWidth = 0.5),
							(r.strokeStyle = "#333"),
							r.strokeRect(c, f, a, s);
					}
				}
			},
			accept: function() {
				return null != this.graph;
			},
			startdrag: function(t) {
				if ((this.enddrag(), this.scale)) {
					var e = this._toGraph(t),
						i = this.graph.viewportBounds;
					i.contains(e[0], e[1]) &&
						((this._dragInfo = { scale: this.scale / this.graph.scale, point: e }), this.graph.stopAnimation());
				}
			},
			ondrag: function(t) {
				if (this._dragInfo) {
					var e = this._dragInfo.scale,
						i = t.dx,
						n = t.dy;
					(i /= e), (n /= e), this.graph.translate(-i, -n, !1);
				}
			},
			enddrag: function() {
				this._dragInfo = null;
			},
			onstart: function(e) {
				t.stopEvent(e);
				var i = this._toGraph(e);
				this.graph.centerTo(i[0], i[1]);
			},
			onmousewheel: function(e) {
				t.stopEvent(e);
				var i = this._toGraph(e);
				(i = this.graph.toCanvas(i[0], i[1])), this.graph.zoomAt(Math.pow(this.graph.scaleStep, e.delta), i.x, i.y);
			},
			ondblclick: function() {
				var t = this.graph;
				if (t.enableDoubleClickToOverview) {
					var e = t.resetScale || 1;
					Math.abs(t.scale - e) < 0.001 ? t.zoomToOverview() : t.moveToCenter(e);
				}
			},
			visible: !0,
			setVisible: function(t) {
				(this.visible = t), (this.html.style.display = t ? "block" : "none"), this._invalidateGraph();
			},
		}),
			(t.Overview = e);
	})(Q),
	(function(t, e) {
		"use strict";
		function i(t, e) {
			this._initEditor(t, e),
				this.loadDatas(
					this.options.data,
					this.options.callback ||
						function() {
							this.graph.moveToCenter();
						}
				);
		}
		var n = function(e, i, n, o) {
				return t.createElement({ class: e, parent: i, tagName: n, html: o });
			},
			o = function(t, e) {
				var i = t.find(e);
				return i.length ? i[0] : void 0;
			};
		e.fn.graphEditor = function(t) {
			return this.each(function() {
				var e = this.graphEditor;
				return e || (this.graphEditor = e = new i(this, t)), e;
			});
		};
		var r = {};
		(r[t.Styles.SHAPE_FILL_COLOR] = t.toColor(3435973836)),
			(r[t.Styles.SELECTION_COLOR] = "#888"),
			(r[t.Styles.SELECTION_SHADOW_BLUR] = 5),
			(r[t.Styles.SELECTION_SHADOW_OFFSET_X] = 2),
			(r[t.Styles.SELECTION_SHADOW_OFFSET_Y] = 2),
			(i.prototype = {
				_initEditor: function(t, i) {
					(this.options = i = i || {}),
						(this.dom = t),
						e(t).addClass("graph-editor"),
						this.createGraph(this.options.styles || r),
						this.createToolbar(i),
						this.createToolbox(this.options.images),
						this.createPropertyPane(i),
						this.createJSONPane(),
						e().borderLayout && (e(t).addClass("layout"), e(t).borderLayout()),
						this.toolbar && this.initToolbar(this.toolbar, this.graph),
						this.initContextMenu(this.graph),
						window.addEventListener("beforeunload", this.onbeforeunload.bind(this));
				},
				onbeforeunload: function() {},
				_getFirst: function(t) {
					return o(e(this.dom), "." + t);
				},
				toolbar: null,
				toolbox: null,
				propertyPane: null,
				graph: null,
				createGraph: function(i) {
					function o(e, i, n) {
						var o;
						return (
							e.forEachReverseVisibleUI(function(e) {
								var r = e.data;
								return r instanceof t.Node && e.uiBounds.intersectsPoint(i - e.x, n - e.y) && e.hitTest(i, n, 1)
									? ((o = r), !1)
									: void 0;
							}),
							o
						);
					}
					var r = this._getFirst("graph-editor__canvas");
					r || ((r = n("graph-editor__canvas", this.dom)), r.setAttribute("data-options", 'region:"center"')), (this.html = r);
					var a = (this.graph = new t.Graph(r));
					return (
						(a.allowEmptyLabel = !0),
						(a.originAtCenter = !1),
						(a.editable = !0),
						(a.styles = i),
						(a.getDropInfo = function(e, i) {
							return i ? t.parseJSON(i) : void 0;
						}),
						(a.dropAction = function() {
							return this.dropAction.apply(this, arguments);
						}.bind(this)),
						e(r).bind("size.change", function() {
							a.updateViewport();
						}),
						a.interactionDispatcher.on(
							function(e) {
								if (
									e.kind == t.InteractionEvent.POINT_MOVE_END &&
									e.data instanceof t.Edge &&
									e.point &&
									e.point.isEndPoint
								) {
									var i = e.data,
										n = e.point,
										r = n.isFrom,
										s = r ? i.from : i.to,
										l = a.toLogical(e.event),
										h = l.x,
										u = l.y,
										p = o(this, h, u);
									if (p && s != p) {
										if (p instanceof t.Group && i.inGroup && i.inGroup(p)) return;
										var d = a.getUI(p).bodyBounds,
											c = { x: h - d.cx, y: u - d.cy };
										i.setStyle(r ? t.Styles.EDGE_FROM_OFFSET : t.Styles.EDGE_TO_OFFSET, c),
											r ? (i.from = p) : (i.to = p);
									}
								}
							}.bind(a)
						),
						a
					);
				},
				dropAction: function(e, i, n) {
					if (n.ondrop) {
						var o = window[n.ondrop];
						if (o instanceof Function) return o.call(this, e, this.graph, i, n), t.stopEvent(e), !1;
					}
				},
				createToolbar: function() {
					var t = this._getFirst("graph-editor__toolbar");
					return t
						? (this.toolbar = t)
						: ((this.toolbar = t = n("graph-editor__toolbar", this.dom)),
						  t.setAttribute("data-options", 'region:"north", height: 40'),
						  t);
				},
				createToolbox: function(e) {
					var i = this._getFirst("graph-editor__toolbox");
					i ||
						((i = document.createElement("div")),
						this.dom.appendChild(i),
						i.setAttribute("data-options", "region:'west', width:'18%', left:0, min-width:220, max-width:400")),
						(this.toolbox = new t.ToolBox(this.graph, i, e)),
						(this.graph.toolbox = this.toolbox);
				},
				createPropertyPane: function(e) {
					if (t.PropertyPane) {
						var i = this._getFirst("graph-editor__property");
						return i || (i = n("graph-editor__property", this.dom)), (this.propertyPane = new t.PropertyPane(this.graph, i, e));
					}
				},
				getJSONTextArea: function() {
					return o(e(this.jsonPane), "textarea");
				},
				loadJSONFile: function(e) {
					e[0] &&
						t.readerSingleFile(
							e[0],
							"json",
							function(t) {
								return t
									? (this.graph.clear(), void this.graph.parseJSON(t))
									: void alert(getI18NString("json file is empty"));
							}.bind(this)
						);
				},
				exportJSONFile: function(t) {
					if (t) {
						var e = this.graph.name || "graph",
							i = this.graph.exportJSON(!0),
							n = new Blob([i], { type: "text/plain;charset=utf-8" });
						t(n, e + ".json");
					}
				},
				exportJSON: function(t) {
					if (t && this.jsonPane) {
						var e = this.graph.exportJSON(!0, { space: "  " });
						return (this.getJSONTextArea().value = e);
					}
					return this.graph.exportJSON.apply(this.graph, arguments);
				},
				submitJSON: function() {
					var t = this.getJSONTextArea().value;
					this.graph.clear(), this.graph.parseJSON(t);
				},
				loadDatas: function(e, i) {
					if (e) {
						if (t.isString(e))
							return void t.loadJSON(
								e,
								function(t) {
									this.graph.parseJSON(t.json || t), i instanceof Function && i.call(this, this);
								}.bind(this),
								function() {
									i instanceof Function && i.call(this, this);
								}.bind(this)
							);
						this.graph.parseJSON(e);
					}
					i instanceof Function && i.call(this, this);
				},
				onsave: function(t) {
					return t ? alert(getI18NString("Save Error")) : void alert(getI18NString("Save Success"));
				},
				save: function() {
					if (this.options.saveService) {
						var t = this.options.saveService,
							e = this.graph.exportJSON(!0),
							i = new XMLHttpRequest();
						i.open("post", t, !0),
							(i.onerror = function(t) {
								this.onsave(t);
							}.bind(this)),
							(i.onload = function(t) {
								200 == t.target.status ? this.onsave(null, t) : this.onsave(t);
							}.bind(this)),
							i.setRequestHeader("Content-Type", "application/json"),
							i.send(JSON.stringify({ name: this.name, json: e }));
					}
				},
				createJSONPane: function() {
					var e = this._getFirst("graph-editor__json");
					if (e) return (this.jsonPane = e);
					this.jsonPane = e = n("graph-editor__json", this.dom);
					var i = document.createElement("textarea");
					e.appendChild(i), (i.spellcheck = !1);
					var o = n("graph-editor__json__buttons", e),
						r = [
							{ name: getI18NString("Update"), action: this.exportJSON.bind(this, !0) },
							{ name: getI18NString("Submit"), action: this.submitJSON.bind(this) },
						];
					return t.createButtonGroup(r, o), (e.style.display = "none"), e;
				},
				initToolbar: function(e, i) {
					var n = [
						{ name: getI18NString("Export JSON"), iconClass: "q-icon toolbar-json", action: this.showJSONPanel.bind(this) },
					];
					t.isFileSupported &&
						n.push({
							iconClass: "q-icon toolbar-upload",
							name: getI18NString("Load File ..."),
							action: this.loadJSONFile.bind(this),
							type: "file",
						}),
						window.saveAs &&
							n.push({
								iconClass: "q-icon toolbar-download",
								name: getI18NString("Download File"),
								action: this.exportJSONFile.bind(this, window.saveAs),
							}),
						this.options.saveService &&
							n.push({ iconClass: "q-icon toolbar-save", name: getI18NString("Save"), action: this.save.bind(this) }),
						t.createToolbar(i, e, { export: n });
				},
				showExportPanel: function() {
					t.showExportPanel(this.graph);
				},
				showJSONPanel: function(t) {
					var i = t.target;
					e(i).hasClass("btn") || (i = i.parentNode);
					var n = e(i).hasClass("active");
					n ? e(i).removeClass("active") : e(i).addClass("active"), (n = !n);
					var o = this.jsonPane;
					(o.style.display = n ? "" : "none"), n && this.exportJSON(!0);
				},
				initContextMenu: function(e) {
					e.popupmenu = new t.PopupMenu();
				},
			}),
			window.localStorage &&
				((i.prototype.loadLocal = function() {
					return localStorage.graph ? (this.graph.clear(), this.graph.parseJSON(localStorage.graph), !0) : void 0;
				}),
				(i.prototype.saveLocal = function() {
					localStorage.graph = this.graph.exportJSON(!0);
				})),
			(t.Editor = i);
	})(Q, jQuery);
